Skip to content

Commit d47b9da

Browse files
author
Konstantin
committed
chore (ci/type-check): run type check in the CI (w/o fixing the issues yet)
mypy --pretty pydifact pydifact\exceptions.py:4: error: Incompatible default for argument "line_number" (default has type "None", argument has type "int") [assignment] self, message: str, line_number: int = None, column_number: int = None ^~~~ pydifact\exceptions.py:4: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True pydifact\exceptions.py:4: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase pydifact\exceptions.py:4: error: Incompatible default for argument "column_number" (default has type "None", argument has type "int") [assignment] self, message: str, line_number: int = None, column_number: int = None ^~~~ pydifact\syntax\common.py:101: error: Need type annotation for "plugins" (hint: "plugins: list[<type>] = ...") [var-annotated] plugins = [] ^~~~~~~ pydifact\syntax\common.py:107: error: Incompatible default for argument "mandatory" (default has type "None", argument has type "bool") [assignment] def validate(self, mandatory: bool = None, repr: str = None) -> None: ^~~~ pydifact\syntax\common.py:107: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True pydifact\syntax\common.py:107: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase pydifact\syntax\common.py:107: error: Incompatible default for argument "repr" (default has type "None", argument has type "str") [assignment] def validate(self, mandatory: bool = None, repr: str = None) -> None: ^~~~ pydifact\syntax\common.py:134: error: Need type annotation for "codes" (hint: "codes: dict[<type>, <type>] = ...") [var-annotated] codes = {} ^~~~~ pydifact\syntax\common.py:138: error: Incompatible types in assignment (expression has type "None", variable has type "list[Any]") [assignment] self.plugins = None ^~~~ pydifact\syntax\common.py:141: error: Incompatible default for argument "mandatory" (default has type "None", argument has type "bool") [assignment] def validate(self, mandatory: bool = None, repr: str = None) -> None: ^~~~ pydifact\syntax\common.py:141: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True pydifact\syntax\common.py:141: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase pydifact\syntax\common.py:141: error: Incompatible default for argument "repr" (default has type "None", argument has type "str") [assignment] def validate(self, mandatory: bool = None, repr: str = None) -> None: ^~~~ pydifact\syntax\common.py:246: error: Invalid type comment or annotation [valid-type] schema: list[tuple[type(DataElement), str, str]] ^ pydifact\syntax\common.py:246: note: Suggestion: use type[...] instead of type(...) pydifact\syntax\common.py:251: error: Incompatible default for argument "mandatory" (default has type "None", argument has type "bool") [assignment] def validate(self, mandatory: bool = None, repeat: int = None) -> None: ^~~~ pydifact\syntax\common.py:251: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True pydifact\syntax\common.py:251: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase pydifact\syntax\common.py:251: error: Incompatible default for argument "repeat" (default has type "None", argument has type "int") [assignment] def validate(self, mandatory: bool = None, repeat: int = None) -> None: ^~~~ pydifact\syntax\common.py:320: error: Argument 1 to "DataElement" has incompatible type "str | None"; expected "str" [arg-type] s = DataElement(value) ^~~~~ pydifact\segments.py:63: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc] def __init__(self, *args: Element): ^ pydifact\segments.py:81: error: Attribute "elements" already defined on line 50 [no-redef] self.elements: Elements = list(args[1:]) ^ pydifact\segments.py:83: error: Attribute "elements" already defined on line 50 [no-redef] self.elements: Elements = list(args) ^ pydifact\segments.py:121: error: Value of type "list[str | list[str]] | None" is not indexable [index] return self.elements[key] if len(self.elements) > key else None ^~~~~~~~~~~~~~~~~~ pydifact\segments.py:121: error: Argument 1 to "len" has incompatible type "list[str | list[str]] | None"; expected "Sized" [arg-type] return self.elements[key] if len(self.elements) > key else None ^~~~~~~~~~~~~ pydifact\segments.py:124: error: Unsupported target for indexed assignment ("list[str | list[str]] | None") [index] self.elements[key] = value ^~~~~~~~~~~~~~~~~~ pydifact\segments.py:142: error: Argument 1 to "enumerate" has incompatible type "list[str | list[str]] | None"; expected "Iterable[str | list[str]]" [arg-type] for index, element in enumerate(self.elements): ^~~~~~~~~~~~~ pydifact\segments.py:163: error: Argument 1 to "CompositeDataElement" has incompatible type "str | list[str]"; expected "list[DataElement]" [arg-type] template_cls(element).validate(mandatory, repr) ^~~~~~~ pydifact\segments.py:163: error: Argument 1 to "DataElement" has incompatible type "str | list[str]"; expected "str" [arg-type] template_cls(element).validate(mandatory, repr) ^~~~~~~ pydifact\segments.py:163: error: Argument 2 to "validate" of "CompositeDataElement" has incompatible type "str"; expected "int" [arg-type] template_cls(element).validate(mandatory, repr) ^~~~ pydifact\serializer.py:76: error: List item 0 has incompatible type "str | list[str] | None"; expected "str" [list-item] collection_parts += [segment.tag] ^~~~~~~~~~~ pydifact\serializer.py:77: error: Item "None" of "list[str | list[str]] | None" has no attribute "__iter__" (not iterable) [union-attr] for element in segment.elements: ^~~~~~~~~~~~~~~~ pydifact\parser.py:126: error: "Characters" has no attribute "is_extracted_from_message" [attr-defined] characters.is_extracted_from_message = True ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\parser.py:236: error: Argument 1 to "create_segment" of "SegmentFactory" has incompatible type "str | list[str]"; expected "str" [arg-type] yield self.factory.create_segment(name, *segment, version=self.version) ^~~~ pydifact\segmentcollection.py:420: error: Value of type "list[str | list[str]] | None" is not indexable [index] assert isinstance(segment.elements[0], str) ^~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:421: error: Value of type "list[str | list[str]] | None" is not indexable [index] assert isinstance(segment.elements[1], list) ^~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:422: error: Value of type "list[str | list[str]] | None" is not indexable [index] message = Message(segment.elements[0], segment.elements[1]) ^~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:487: error: Argument 1 to "len" has incompatible type "list[str | list[str]] | None"; expected "Sized" [arg-type] if len(unb.elements) < 4: ^~~~~~~~~~~~ pydifact\segmentcollection.py:493: error: Value of type "list[str | list[str]] | None" is not indexable [index] if isinstance(unb.elements[3], list) and len(unb.elements[3]) > 0: ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:494: error: Value of type "list[str | list[str]] | None" is not indexable [index] if len(unb.elements[3][0]) == 6: ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:496: error: Value of type "list[str | list[str]] | None" is not indexable [index] elif len(unb.elements[3][0]) == 8: ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:504: error: Value of type "list[str | list[str]] | None" is not indexable [index] isinstance(unb.elements[0], list) ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:505: error: Value of type "list[str | list[str]] | None" is not indexable [index] and len(unb.elements[0]) == 2 ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:506: error: Value of type "list[str | list[str]] | None" is not indexable [index] and unb.elements[0][1].isdecimal() ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:508: error: Value of type "list[str | list[str]] | None" is not indexable [index] syntax_identifier = (unb.elements[0][0], int(unb.elements[0][1])) ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:512: error: Value of type "list[str | list[str]] | None" is not indexable [index] datetime_str = "-".join(unb.elements[3]) ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:516: error: Value of type "list[str | list[str]] | None" is not indexable [index] sender=unb.elements[1], ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:517: error: Value of type "list[str | list[str]] | None" is not indexable [index] recipient=unb.elements[2], ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:519: error: Value of type "list[str | list[str]] | None" is not indexable [index] control_reference=unb.elements[4], ^~~~~~~~~~~~~~~ pydifact\segmentcollection.py:521: error: Value of type "list[str | list[str]] | None" is not indexable [index] extra_header_elements=unb.elements[5:], ^~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:524: error: Value of type "list[str | list[str]] | None" is not indexable [index] if first_segment.tag == "UNA" and isinstance(first_segment.elements[0], str): ^~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:526: error: Value of type "list[str | list[str]] | None" is not indexable [index] interchange.characters = Characters.from_str(first_segment.elements[0]) ^~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:541: error: Value of type "list[str | list[str]] | None" is not indexable [index] assert isinstance(segment.elements[0], str) ^~~~~~~~~~~~~~~~~~~ pydifact\segmentcollection.py:542: error: Value of type "list[str | list[str]] | None" is not indexable [index] self.characters = Characters.from_str(segment.elements[0]) ^~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:202: error: List item 0 has incompatible type "type[PartyName]"; expected "tuple[Any, str, str]" [list-item] PartyName, ^~~~~~~~~ pydifact\syntax\v1\__init__.py:203: error: List item 1 has incompatible type "type[PartyName]"; expected "tuple[Any, str, str]" [list-item] PartyName, ^~~~~~~~~ pydifact\syntax\v1\__init__.py:204: error: List item 2 has incompatible type "type[PartyName]"; expected "tuple[Any, str, str]" [list-item] PartyName, ^~~~~~~~~ pydifact\syntax\v1\__init__.py:205: error: List item 3 has incompatible type "type[PartyName]"; expected "tuple[Any, str, str]" [list-item] PartyName, ^~~~~~~~~ pydifact\syntax\v1\__init__.py:206: error: List item 4 has incompatible type "type[PartyName]"; expected "tuple[Any, str, str]" [list-item] PartyName, ^~~~~~~~~ pydifact\syntax\v1\__init__.py:207: error: List item 5 has incompatible type "type[PartyNameFormat]"; expected "tuple[Any, str, str]" [list-item] PartyNameFormat, ^~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:213: error: List item 0 has incompatible type "type[NameAndAddressLine]"; expected "tuple[Any, str, str]" [list-item] schema = [NameAndAddressLine] ^~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:264: error: List item 0 has incompatible type "tuple[type[ServiceStringAdvice], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (ServiceStringAdvice, C, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:274: error: List item 0 has incompatible type "Characters"; expected "str | list[str]" [list-item] self.elements = [characters] ^~~~~~~~~~ pydifact\syntax\v1\__init__.py:295: error: List item 0 has incompatible type "tuple[type[CSyntaxIdentifier], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CSyntaxIdentifier, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:296: error: List item 1 has incompatible type "tuple[type[CInterchangeSender], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CInterchangeSender, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:297: error: List item 2 has incompatible type "tuple[type[CInterchangeRecipient], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CInterchangeRecipient, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:298: error: List item 3 has incompatible type "tuple[type[CDateAndTimeOfPreparation], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CDateAndTimeOfPreparation, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:299: error: List item 4 has incompatible type "tuple[type[InterchangeControlReference], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (InterchangeControlReference, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v1\__init__.py:300: error: List item 5 has incompatible type "tuple[type[CRecipientsReference], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CRecipientsReference, C, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:232: error: List item 0 has incompatible type "tuple[type[CSyntaxIdentifier], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CSyntaxIdentifier, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:233: error: List item 1 has incompatible type "tuple[type[CInterchangeSender], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CInterchangeSender, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:234: error: List item 2 has incompatible type "tuple[type[CInterchangeRecipient], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CInterchangeRecipient, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:235: error: List item 3 has incompatible type "tuple[type[CDateAndTimeOfPreparation], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CDateAndTimeOfPreparation, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:236: error: List item 4 has incompatible type "tuple[type[InterchangeControlReference], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (InterchangeControlReference, M, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pydifact\syntax\v4\__init__.py:237: error: List item 5 has incompatible type "tuple[type[CRecipientReferencePassword], str, int]"; expected "tuple[type[CompositeDataElement] | type[DataElement], str, int, str]" [list-item] (CRecipientReferencePassword, C, 1), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Found 68 errors in 8 files (checked 20 source files)
1 parent a56aeea commit d47b9da

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/typecheck.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Type Check"
2+
3+
on: [push, pull_request]
4+
jobs:
5+
pytest:
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
matrix:
9+
python-version: ["3.13"]
10+
os: [ubuntu-latest]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install Dev Dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install .[dev]
21+
- name: Run Type Check
22+
run: |
23+
make mypy

0 commit comments

Comments
 (0)