From 2587354411cbae200daa39f638fbd0dcb8d3e847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Wi=C5=9Bniewski?= Date: Tue, 16 Apr 2024 23:45:45 +0200 Subject: [PATCH] Fix mypy issues in _load_py_cssfproject --- cssfinder/cssfproject.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cssfinder/cssfproject.py b/cssfinder/cssfproject.py index 39b9150..2d4a10c 100644 --- a/cssfinder/cssfproject.py +++ b/cssfinder/cssfproject.py @@ -224,7 +224,7 @@ def _load_py_cssfproject(cls, project_path: Path) -> Self: project_module = importlib.util.module_from_spec(spec) spec.loader.exec_module(project_module) - project_object: CSSFProject = getattr(project_module, "__project__", None) + project_object = getattr(project_module, "__project__", None) if project_object is None: msg = ( @@ -233,6 +233,14 @@ def _load_py_cssfproject(cls, project_path: Path) -> Self: ) raise ImportError(msg) + if not isinstance(project_object, cls): + msg = ( + f"Expected CSSFProject object in '__project__' field in {project_path}." + ) + raise TypeError( + msg, + ) + if not isinstance(project_object, cls): msg = ( "Incorrect object in '__project__' field, should contain "