diff --git a/.github/workflows/test-elementpath.yml b/.github/workflows/test-elementpath.yml index 0f32ba29..7afbe97d 100644 --- a/.github/workflows/test-elementpath.yml +++ b/.github/workflows/test-elementpath.yml @@ -45,7 +45,7 @@ jobs: if: ${{ matrix.python-version != '3.7' && matrix.python-version == 'pypy-3.8' }} run: | pip install mypy==0.950 - mypy --show-error-codes elementpath + mypy --show-error-codes --strict elementpath - name: Test with unittest run: | pip install lxml xmlschema>=1.9.0 diff --git a/elementpath/regex/unicode_subsets.py b/elementpath/regex/unicode_subsets.py index e545564d..cd1fd29f 100644 --- a/elementpath/regex/unicode_subsets.py +++ b/elementpath/regex/unicode_subsets.py @@ -326,7 +326,7 @@ def __eq__(self, other: object) -> bool: else: return self._codepoints == other - def __ior__(self, other: object) -> 'UnicodeSubset': # type: ignore[override] + def __ior__(self, other: object) -> 'UnicodeSubset': if not isinstance(other, Iterable): return NotImplemented elif isinstance(other, UnicodeSubset): @@ -376,7 +376,7 @@ def __and__(self, other: object) -> 'UnicodeSubset': obj = self.copy() return obj.__iand__(other) - def __ixor__(self, other: object) -> 'UnicodeSubset': # type: ignore[override] + def __ixor__(self, other: object) -> 'UnicodeSubset': if other is self: self.clear() return self diff --git a/elementpath/tdop.py b/elementpath/tdop.py index 8b65d080..b0995c5b 100644 --- a/elementpath/tdop.py +++ b/elementpath/tdop.py @@ -357,7 +357,7 @@ def wrong_value(self, message: str = 'invalid value') -> ValueError: class ParserMeta(ABCMeta): - token_base_class: Type[Token[Any]] + token_base_class: Type[Any] literals_pattern: Pattern[str] name_pattern: Pattern[str] tokenizer: Optional[Pattern[str]] diff --git a/elementpath/xpath30/xpath30_helpers.py b/elementpath/xpath30/xpath30_helpers.py index 6f593d4e..9f3be25a 100644 --- a/elementpath/xpath30/xpath30_helpers.py +++ b/elementpath/xpath30/xpath30_helpers.py @@ -453,6 +453,9 @@ def parse_datetime_marker(marker: str, dt: datetime.datetime, lang: Optional[str else: zero_cp, zero_ch = ord('0'), '0' + min_width: int + max_width: Optional[int] + digits = sum(c.isdigit() for c in presentation) opt_digits = presentation.count('#') if not width or width == '*': diff --git a/elementpath/xpath_context.py b/elementpath/xpath_context.py index 80b09b6a..0235369e 100644 --- a/elementpath/xpath_context.py +++ b/elementpath/xpath_context.py @@ -12,7 +12,7 @@ from itertools import chain from types import ModuleType from typing import TYPE_CHECKING, cast, Dict, Any, List, Iterator, \ - Optional, Sequence, Union, Callable, MutableMapping, Set, Tuple + Optional, Sequence, Union, Callable, MutableMapping, Set from .exceptions import ElementPathTypeError, ElementPathValueError from .namespaces import XML_NAMESPACE @@ -586,7 +586,7 @@ def iter_descendants(self, axis: Optional[str] = None, In this case set the context size at start and change both position and \ item at each iteration. For default only context item is changed. """ - descendants: Union[Iterator[Union[XPathNodeType, None]], Tuple[XPathNode]] + descendants: Any with_self = axis != 'descendant' if self.item is None: diff --git a/mypy.ini b/mypy.ini index a0eb185a..7024cfde 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,2 @@ [mypy] show_error_codes = True -warn_unused_ignores = True \ No newline at end of file diff --git a/tox.ini b/tox.ini index e5665ad1..b61df1d5 100644 --- a/tox.ini +++ b/tox.ini @@ -38,13 +38,20 @@ deps = commands = flake8 elementpath -[testenv:mypy-py{37,38,39,310}] +[testenv:mypy-py37] deps = mypy==0.950 commands = mypy --config-file {toxinidir}/mypy.ini elementpath python tests/test_typing.py +[testenv:mypy-py{38,39,310}] +deps = + mypy==0.950 +commands = + mypy --config-file {toxinidir}/mypy.ini --strict elementpath + python tests/test_typing.py + [testenv:coverage] commands = coverage run -p -m unittest