Skip to content

Commit

Permalink
Merge branch 'main' into patch_linting_issues_for_version_bump_pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein committed May 17, 2024
2 parents b3241af + 1ff4236 commit 4ae44f4
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pydantic-core==2.18.2
# via pydantic
python-dateutil==2.9.0.post0
# via pandas
python-docx==1.1.0
python-docx==1.1.2
# via kohlrahbi (pyproject.toml)
pytz==2024.1
# via
Expand Down
6 changes: 3 additions & 3 deletions src/kohlrahbi/ahb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from typing import Any, Dict, Optional

import click
import docx # type: ignore
import docx
import tomlkit
from docx.document import Document # type:ignore[import]
from docx.table import Table # type:ignore[import]
from docx.document import Document
from docx.table import Table
from maus.edifact import EdifactFormatVersion

from kohlrahbi.ahbtable.ahbtable import AhbTable
Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/ahbtable/ahbcondtions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
from pathlib import Path

from docx.table import Table as DocxTable # type: ignore[import-untyped]
from docx.table import Table as DocxTable
from maus.edifact import EdifactFormat
from pydantic import BaseModel, ConfigDict

Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/ahbtable/ahbpackagetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class which contains AHB package condition table
from pathlib import Path

import pandas as pd
from docx.table import Table as DocxTable # type: ignore[import-untyped]
from docx.table import Table as DocxTable
from maus.edifact import EdifactFormat
from pydantic import BaseModel, ConfigDict

Expand Down
4 changes: 2 additions & 2 deletions src/kohlrahbi/ahbtable/ahbsubtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Generator

import pandas as pd
from docx.table import Table as DocxTable # type:ignore[import]
from docx.table import _Cell # type:ignore[import]
from docx.table import Table as DocxTable
from docx.table import _Cell
from pydantic import BaseModel, ConfigDict

from kohlrahbi.ahbtable.ahbtablerow import AhbTableRow
Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/ahbtable/ahbtablerow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Optional

import pandas as pd
from docx.table import _Cell # type:ignore[import]
from docx.table import _Cell
from pydantic import BaseModel, ConfigDict

from kohlrahbi.docxtablecells import BedingungCell, BodyCell, EdifactStrukturCell
Expand Down
6 changes: 3 additions & 3 deletions src/kohlrahbi/changehistory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from pathlib import Path
from typing import Optional

import docx # type: ignore
import docx
import pandas as pd
from docx.document import Document # type:ignore[import]
from docx.table import Table # type: ignore
from docx.document import Document
from docx.table import Table

from kohlrahbi.changehistory.changehistorytable import ChangeHistoryTable
from kohlrahbi.docxfilefinder import DocxFileFinder
Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/changehistory/changehistorytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import pandas as pd
from docx.table import Table # type:ignore[import]
from docx.table import Table
from pydantic import BaseModel, ConfigDict

from kohlrahbi.ahbtable.ahbsubtable import AhbSubTable
Expand Down
5 changes: 3 additions & 2 deletions src/kohlrahbi/conditions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pathlib import Path

import docx # type: ignore[import-untyped]
import docx
from maus.edifact import EdifactFormat, EdifactFormatVersion, get_format_of_pruefidentifikator

from kohlrahbi.ahb import get_pruefi_to_file_mapping
Expand Down Expand Up @@ -46,7 +46,8 @@ def scrape_conditions(
for file in files:
# pylint: disable=too-many-function-args
# type: ignore[call-arg, arg-type]
doc = docx.Document(basic_input_path / path_to_file / Path(file))
path: Path = basic_input_path / path_to_file / Path(file)
doc = docx.Document(str(path.absolute()))
logger.info("Start scraping conditions for %s in %s", edifact_format, file)
if not doc:
logger.error("Could not open file %s as docx", Path(file))
Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/docxtablecells/bedinungscell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re

import pandas as pd
from docx.table import _Cell # type:ignore[import]
from docx.table import _Cell
from pydantic import BaseModel, ConfigDict


Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/docxtablecells/bodycell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import pandas as pd
from docx.table import _Cell # type:ignore[import]
from docx.table import _Cell
from maus.reader.flat_ahb_reader import FlatAhbCsvReader
from pydantic import BaseModel, ConfigDict

Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/docxtablecells/edifactstrukturcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re

import pandas as pd
from docx.table import _Cell # type:ignore[import]
from docx.table import _Cell
from pydantic import BaseModel, ConfigDict

_segment_group_pattern = re.compile(r"^SG\d+$")
Expand Down
14 changes: 7 additions & 7 deletions src/kohlrahbi/read_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
A collection of functions to get information from AHB tables.
"""

from typing import Generator, Optional, Tuple, Union
from typing import Generator, Optional, Tuple, TypeGuard, Union

from docx.document import Document # type:ignore[import]
from docx.oxml.table import CT_Tbl # type:ignore[import]
from docx.oxml.text.paragraph import CT_P # type:ignore[import]
from docx.table import Table, _Cell # type:ignore[import]
from docx.text.paragraph import Paragraph # type:ignore[import]
from docx.document import Document
from docx.oxml.table import CT_Tbl
from docx.oxml.text.paragraph import CT_P
from docx.table import Table, _Cell
from docx.text.paragraph import Paragraph
from maus.edifact import EdifactFormat, get_format_of_pruefidentifikator

from kohlrahbi.ahbtable.ahbcondtions import AhbConditions
Expand Down Expand Up @@ -275,7 +275,7 @@ def is_last_row_unt_0062(item: Table | Paragraph) -> bool:
return isinstance(item, Table) and "UNT\t0062" == item.cell(row_idx=-1, col_idx=0).text.strip()


def is_relevant_pruefi_table(item: Paragraph | Table, seed: Seed, edifact_format) -> bool:
def is_relevant_pruefi_table(item: Paragraph | Table, seed: Seed, edifact_format) -> TypeGuard[Table]:
"""compares new pruefis to last pruefi and thus checks whether new table"""
return (
isinstance(item, Table)
Expand Down
8 changes: 4 additions & 4 deletions src/kohlrahbi/row_type_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This module contains all functions to define the type of a row of the tables in an AHB.
"""

from docx.oxml.ns import qn # type:ignore[import]
from docx.oxml.parser import OxmlElement # type:ignore[import]
from docx.shared import RGBColor # type:ignore[import]
from docx.table import _Cell # type:ignore[import]
from docx.oxml.ns import qn
from docx.oxml.parser import OxmlElement
from docx.shared import RGBColor
from docx.table import _Cell

from kohlrahbi.enums import RowType

Expand Down
2 changes: 1 addition & 1 deletion src/kohlrahbi/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module provides a class to collect information which of need for all parsing functions
"""

from docx.table import Table # type:ignore[import]
from docx.table import Table
from pydantic import BaseModel

from kohlrahbi.enums import RowType
Expand Down
4 changes: 2 additions & 2 deletions src/kohlrahbi/table_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from enum import StrEnum
from typing import Dict, List, Mapping, cast

from docx.table import _Cell # type:ignore[import]
from docx.text.paragraph import Paragraph # type:ignore[import]
from docx.table import _Cell
from docx.text.paragraph import Paragraph
from more_itertools import first, last
from pydantic import BaseModel

Expand Down
2 changes: 1 addition & 1 deletion unittests/cellparagraph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from attr import define, field
from docx.shared import Length # type:ignore[import]
from docx.shared import Length


@define(auto_attribs=True, kw_only=True)
Expand Down
2 changes: 1 addition & 1 deletion unittests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import docx # type:ignore[import]
import docx
import pytest # type:ignore[import]

from unittests.cellparagraph import CellParagraph
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_ahb_sub_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from pathlib import Path

import docx # type:ignore[import]
from docx.table import Table # type:ignore[import]
import docx
from docx.table import Table

from kohlrahbi.ahbtable.ahbsubtable import AhbSubTable
from kohlrahbi.read_functions import get_all_paragraphs_and_tables
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_cells/test_bedingung_cell_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd
import pytest # type:ignore[import]
from docx.shared import Twips # type:ignore[import]
from docx.shared import Twips

from kohlrahbi.docxtablecells import BedingungCell
from unittests.cellparagraph import CellParagraph
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_cells/test_body_cell_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd
import pytest # type:ignore[import]
from docx.shared import Length, Twips # type:ignore[import]
from docx.shared import Length, Twips

from kohlrahbi.docxtablecells import BodyCell
from unittests.cellparagraph import CellParagraph
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_cells/test_edifact_struktur_cell_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd
import pytest # type:ignore[import]
from docx.shared import Twips # type:ignore[import]
from docx.shared import Twips

from kohlrahbi.docxtablecells import EdifactStrukturCell
from unittests.cellparagraph import CellParagraph
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_check_row_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import docx # type:ignore[import]
import docx
import pytest # type:ignore[import]
from docx.shared import RGBColor # type:ignore[import]
from docx.shared import RGBColor

from kohlrahbi.row_type_checker import RowType, get_row_type

Expand Down
12 changes: 7 additions & 5 deletions unittests/test_docx_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
tests all the features the kohlrahbi package provides to process Docx files (by using the docx package)
"""

from typing import Generator

import pytest # type:ignore[import]
from _pytest.fixtures import SubRequest # type:ignore[import]
from docx import Document # type:ignore[import]
from docx.document import Document as DocumentClass # type:ignore[import]
from docx.table import Table # type:ignore[import]
from docx.text.paragraph import Paragraph # type:ignore[import]
from docx import Document
from docx.document import Document as DocumentClass
from docx.table import Table
from docx.text.paragraph import Paragraph

from kohlrahbi.read_functions import get_all_paragraphs_and_tables


class TestDocxExtensions:
@pytest.fixture
def create_docx_from_filename(self, request: SubRequest, datafiles) -> DocumentClass:
def create_docx_from_filename(self, request: SubRequest, datafiles) -> Generator[DocumentClass, None, None]:
"""a fixture to quickly instantiate a docx.Document from a given docx file name"""
docx_file_name = request.param
docx_file_path = datafiles / docx_file_name
Expand Down
3 changes: 1 addition & 2 deletions unittests/test_read_functions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json
import os
from pathlib import Path

import docx # type:ignore[import]
import docx
import pytest # type:ignore[import]
from docx import Document
from maus.edifact import EdifactFormat, EdifactFormatVersion
Expand Down

0 comments on commit 4ae44f4

Please sign in to comment.