diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11a5c88..c90fd99 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: fail-fast: false matrix: python-version: ["3.13"] - tox-job: ["linters", "twine-check"] + tox-job: ["linters", "mypy", "twine-check"] steps: - uses: actions/checkout@v4 diff --git a/duplicate_url_discarder_rules/__init__.py b/duplicate_url_discarder_rules/__init__.py index b6bb37b..26ae940 100644 --- a/duplicate_url_discarder_rules/__init__.py +++ b/duplicate_url_discarder_rules/__init__.py @@ -16,7 +16,7 @@ RULE_PATHS_ARTICLE: List[str] = [] RULE_PATHS_PRODUCT: List[str] = [] -for path in RULE_PATHS: +for path in RULE_PATHS or []: filename = Path(path).name if filename == "article.json": RULE_PATHS_ARTICLE.append(path) diff --git a/pyproject.toml b/pyproject.toml index a55df0b..9bc7664 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,3 +40,15 @@ target-version = ["py39", "py310", "py311", "py312", "py313"] [tool.isort] profile = "black" multi_line_output = 3 + +[tool.mypy] +strict = true +implicit_reexport = true + +[[tool.mypy.overrides]] +module = "tests.*.*" +disallow_untyped_defs = false + +[[tool.mypy.overrides]] +module = "url_matcher" +ignore_missing_imports = true diff --git a/tests/normalizer/test_normalizer.py b/tests/normalizer/test_normalizer.py index c520993..5c12f11 100644 --- a/tests/normalizer/test_normalizer.py +++ b/tests/normalizer/test_normalizer.py @@ -5,6 +5,7 @@ def test_normalizer_main_rules(): + assert RULE_PATHS is not None rule_path = [path for path in RULE_PATHS if path.endswith("normalizer/main.json")] assert len(rule_path) == 1 diff --git a/tests/queryRemovalExcept/test_query_removal_except.py b/tests/queryRemovalExcept/test_query_removal_except.py index cfbddf5..f855e36 100644 --- a/tests/queryRemovalExcept/test_query_removal_except.py +++ b/tests/queryRemovalExcept/test_query_removal_except.py @@ -5,6 +5,7 @@ def test_query_removal_except_product_rules(): + assert RULE_PATHS is not None rule_path = [ path for path in RULE_PATHS if path.endswith("queryRemovalExcept/product.json") ] diff --git a/tests/subpathRemoval/test_subpath_removal.py b/tests/subpathRemoval/test_subpath_removal.py index 8284d55..16f4337 100644 --- a/tests/subpathRemoval/test_subpath_removal.py +++ b/tests/subpathRemoval/test_subpath_removal.py @@ -5,6 +5,7 @@ def test_subpath_removal_product_rules(): + assert RULE_PATHS is not None rule_path = [ path for path in RULE_PATHS if path.endswith("subpathRemoval/product.json") ] diff --git a/tests/test_rules.py b/tests/test_rules.py index 3e391d7..b774bfd 100644 --- a/tests/test_rules.py +++ b/tests/test_rules.py @@ -11,6 +11,7 @@ def test_rule_validity(): + assert RULE_PATHS is not None for path in RULE_PATHS: try: with open(path, "r") as f: @@ -45,6 +46,7 @@ def test_rule_validity(): def test_rules_concat(): + assert RULE_PATHS is not None all_rules = RULE_PATHS_COMMON + RULE_PATHS_ARTICLE + RULE_PATHS_PRODUCT assert isinstance(all_rules, list) for path in all_rules: diff --git a/tox.ini b/tox.ini index 217c2db..a28e146 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py39,py310,py311,py312,py313,linters,twine-check +envlist = py39,py310,py311,py312,py313,linters,mypy,twine-check [testenv] deps = @@ -15,6 +15,12 @@ commands = deps = pre-commit commands = pre-commit run --all-files --show-diff-on-failure +[testenv:mypy] +deps = + mypy==1.13.0 + duplicate-url-discarder +commands = mypy duplicate_url_discarder_rules tests + [testenv:twine-check] deps = build