Skip to content

Commit

Permalink
aaaalter
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein committed May 17, 2024
1 parent f11b615 commit f4cdcfc
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/kohlrahbi/ahbtable/ahbtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def append_ahb_sub_table(self, ahb_sub_table: AhbSubTable) -> None:
self.table = pd.concat([self.table, ahb_sub_table.table], ignore_index=True)

@staticmethod
def line_contains_only_segment_gruppe(raw_line: pd.Series) -> bool:
def line_contains_only_segment_gruppe(raw_line: pd.Series[str]) -> bool:
"""
Returns true if the given raw line only contains some meaningful data in the "Segment Gruppe" key
"""
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 @@ -54,7 +54,7 @@ def is_empty(val: str) -> bool:
return pd.isna(val) or val == ""

# Define a function to check if a value is considered empty for our case
def is_the_first_column_empty(row: pd.Series) -> bool:
def is_the_first_column_empty(row: pd.Series[str]) -> bool:
"""
Checks if the first column of the given row is empty.
This is our indicator if the current row is a continuation of the upper row.
Expand Down
16 changes: 8 additions & 8 deletions src/kohlrahbi/read_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ def is_item_table_with_pruefidentifikatoren(item: Paragraph | Table | None) -> T


def is_item_headless_table(
item: Paragraph | Table | None,
# seed: Seed | None,
ahb_table: AhbTable | None,
) -> TypeGuard[Table]:
value: tuple[Union[Paragraph, Table, None], Union[AhbTable, None]]
) -> TypeGuard[tuple[Table, AhbTable]]:
"""
Checks if the given item is a headless table.
Expand All @@ -93,6 +91,7 @@ def is_item_headless_table(
Returns:
bool: True if the item is a headless table, False otherwise.
"""
item, ahb_table = value
# return isinstance(item, Table) and seed is not None and ahb_table is not None
return isinstance(item, Table) and ahb_table is not None

Expand Down Expand Up @@ -171,7 +170,7 @@ def process_table(
item: Paragraph | Table | None,
pruefi: str,
searched_pruefi_is_found: bool,
ahb_table: AhbTable,
ahb_table: AhbTable | None,
seed: Seed | None = None,
) -> tuple[bool, AhbTable]:
"""Processes tables to find and build the AHB table."""
Expand All @@ -184,12 +183,13 @@ def process_table(
ahb_table = AhbTable.from_ahb_sub_table(ahb_sub_table=ahb_sub_table)
searched_pruefi_is_found = True

# elif is_item_headless_table(item, seed, ahb_table):
elif is_item_headless_table(item, ahb_table):
elif is_item_headless_table((item, ahb_table)):
assert ahb_table is not None
assert isinstance(item, Table)
assert seed is not None
ahb_sub_table = AhbSubTable.from_headless_table(docx_table=item, tmd=seed)
ahb_table.append_ahb_sub_table(ahb_sub_table=ahb_sub_table)

assert ahb_table is not None
return searched_pruefi_is_found, ahb_table


Expand Down
14 changes: 7 additions & 7 deletions src/kohlrahbi/unfoldedahb/unfoldedahbtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _get_section_name(segment_gruppe_or_section_name: str, last_section_name: st
return last_section_name

@staticmethod
def _is_section_name(ahb_row: pd.Series) -> bool:
def _is_section_name(ahb_row: pd.Series[str]) -> bool:
"""
Checks if the current AHB row is a section name.
It uses the same logic as the function 'line_contains_only_segment_gruppe'
Expand All @@ -245,15 +245,15 @@ def _is_section_name(ahb_row: pd.Series) -> bool:
return AhbTable.line_contains_only_segment_gruppe(ahb_row)

@staticmethod
def _is_segment_group(ahb_row: pd.Series) -> bool:
def _is_segment_group(ahb_row: pd.Series[str]) -> bool:
"""Checks if the current AHB row is a segment group."""

if _segment_group_pattern.match(ahb_row["Segment Gruppe"]) and not ahb_row["Segment"]:
return True
return False

@staticmethod
def _is_segment_opening_line(ahb_row: pd.Series) -> bool:
def _is_segment_opening_line(ahb_row: pd.Series[str]) -> bool:
"""Checks if the current AHB row is a segment opening line.
Example:
Expand All @@ -273,7 +273,7 @@ def _is_segment_opening_line(ahb_row: pd.Series) -> bool:
return False

@staticmethod
def _is_just_segment(ahb_row: pd.Series) -> bool:
def _is_just_segment(ahb_row: pd.Series[str]) -> bool:
"""
Checks if the given AHB row is a segment
"""
Expand All @@ -287,7 +287,7 @@ def _is_just_segment(ahb_row: pd.Series) -> bool:
return False

@staticmethod
def _is_dataelement(ahb_row: pd.Series) -> bool:
def _is_dataelement(ahb_row: pd.Series[str]) -> bool:
"""
Checks if the given AHB row is a dataelement
"""
Expand All @@ -296,12 +296,12 @@ def _is_dataelement(ahb_row: pd.Series) -> bool:
return False

@staticmethod
def _is_just_value_pool_entry(ahb_row: pd.Series) -> bool:
def _is_just_value_pool_entry(ahb_row: pd.Series[str]) -> bool:
"""
Checks if the given AHB row contains only a value pool entry (w/o Segment (group) and data element)
"""
return (
(not ahb_row["Segment Gruppe"])
(not ahb_row["Segment Gruppe"]) # type:ignore[return-value]
and (not ahb_row["Segment"])
and (not ahb_row["Datenelement"])
and ahb_row["Codes und Qualifier"]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ deps =
-r dev_requirements/requirements-type_check.txt
commands =
mypy --show-error-codes src/kohlrahbi --strict
mypy --show-error-codes unittests --strict
mypy --show-error-codes unittests
# mypy --show-error-codes unittests # does not work yet, sadly; Some tox/packaging problems
# add single files (ending with .py) or packages here

Expand Down
2 changes: 1 addition & 1 deletion unittests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import docx
import pytest # type:ignore[import]
import pytest

from unittests.cellparagraph import CellParagraph

Expand Down
2 changes: 1 addition & 1 deletion unittests/test_ahb_file_finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

import pytest # type:ignore[import]
import pytest
from maus.edifact import EdifactFormat

from kohlrahbi.docxfilefinder import DocxFileFinder
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_ahb_table.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

import pandas as pd
import pytest # type:ignore[import]
import pytest

from kohlrahbi.ahbtable.ahbtable import AhbTable
from kohlrahbi.unfoldedahb import UnfoldedAhb
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,5 +1,5 @@
import pandas as pd
import pytest # type:ignore[import]
import pytest
from docx.shared import Twips

from kohlrahbi.docxtablecells import BedingungCell
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,5 +1,5 @@
import pandas as pd
import pytest # type:ignore[import]
import pytest
from docx.shared import Length, Twips

from kohlrahbi.docxtablecells import BodyCell
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,5 +1,5 @@
import pandas as pd
import pytest # type:ignore[import]
import pytest
from docx.shared import Twips

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

from kohlrahbi.row_type_checker import RowType, get_row_type
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_cli_pruefi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Union

import pytest # type:ignore[import]
import pytest
from click.testing import CliRunner, Result

from kohlrahbi.ahb.command import ahb
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_conditions_format_file_mapping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest # type:ignore[import]
import pytest
from maus.edifact import EdifactFormat

from kohlrahbi.conditions import find_all_files_from_all_pruefis
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_current_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Union

import pandas as pd
import pytest # type:ignore[import]
import pytest
from click.testing import CliRunner, Result

from kohlrahbi import cli
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_docx_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import Generator

import pytest # type:ignore[import]
import pytest
from _pytest.fixtures import SubRequest # type:ignore[import]
from docx import Document
from docx.document import Document as DocumentClass
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_input_checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest # type:ignore[import]
import pytest

from kohlrahbi.ahb import get_valid_pruefis

Expand Down
2 changes: 1 addition & 1 deletion unittests/test_read_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

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

Expand Down
2 changes: 1 addition & 1 deletion unittests/test_table_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Test the table_header module.
"""

import pytest # type:ignore[import]
import pytest

from kohlrahbi.table_header import create_mapping_of_tabstop_positions

Expand Down

0 comments on commit f4cdcfc

Please sign in to comment.