From 82322f7a6c5fdb9cd0b80a43432778205d3472e3 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Thu, 9 Feb 2023 22:46:08 +0200 Subject: [PATCH] mask mypy warning The newest mypy produces the following warning: src/ahriman/application/handlers/search.py:43: error: Non-overlapping identity check (left operand type: "Union[_DefaultFactory[Any], Literal[_MISSING_TYPE.MISSING]]", right operand type: "Type[List[Any]]") [comparison-overlap] which is more likely caused by updated dataclass models to protoocol (however decorators are still calllable). This commit masks problematic line from checking --- src/ahriman/application/handlers/search.py | 2 +- tests/ahriman/application/handlers/test_handler_search.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ahriman/application/handlers/search.py b/src/ahriman/application/handlers/search.py index 72f2f433..de451b11 100644 --- a/src/ahriman/application/handlers/search.py +++ b/src/ahriman/application/handlers/search.py @@ -40,7 +40,7 @@ class Search(Handler): """ ALLOW_AUTO_ARCHITECTURE_RUN = False # it should be called only as "no-architecture" - SORT_FIELDS = {field.name for field in fields(AURPackage) if field.default_factory is not list} + SORT_FIELDS = {field.name for field in fields(AURPackage) if field.default_factory is not list} # type: ignore @classmethod def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, configuration: Configuration, *, diff --git a/tests/ahriman/application/handlers/test_handler_search.py b/tests/ahriman/application/handlers/test_handler_search.py index 25ee83ae..47c2dd7b 100644 --- a/tests/ahriman/application/handlers/test_handler_search.py +++ b/tests/ahriman/application/handlers/test_handler_search.py @@ -131,9 +131,10 @@ def test_disallow_auto_architecture_run() -> None: assert not Search.ALLOW_AUTO_ARCHITECTURE_RUN -def test_sort_fields() -> None: +def test_sort_fields(aur_package_ahriman: AURPackage) -> None: """ must store valid field list which are allowed to be used for sorting """ expected = {field.name for field in dataclasses.fields(AURPackage)} assert all(field in expected for field in Search.SORT_FIELDS) + assert all(not isinstance(getattr(aur_package_ahriman, field), list) for field in Search.SORT_FIELDS)