Skip to content

Commit 11d565a

Browse files
committed
Add mypy.
1 parent 68a40a3 commit 11d565a

File tree

8 files changed

+26
-3
lines changed

8 files changed

+26
-3
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
python-version: ["3.13"]
45-
tox-job: ["linters", "twine-check"]
45+
tox-job: ["linters", "mypy", "twine-check"]
4646

4747
steps:
4848
- uses: actions/checkout@v4

duplicate_url_discarder_rules/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
RULE_PATHS_ARTICLE: List[str] = []
1717
RULE_PATHS_PRODUCT: List[str] = []
1818

19-
for path in RULE_PATHS:
19+
for path in RULE_PATHS or []:
2020
filename = Path(path).name
2121
if filename == "article.json":
2222
RULE_PATHS_ARTICLE.append(path)

pyproject.toml

+12
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ target-version = ["py39", "py310", "py311", "py312", "py313"]
4040
[tool.isort]
4141
profile = "black"
4242
multi_line_output = 3
43+
44+
[tool.mypy]
45+
strict = true
46+
implicit_reexport = true
47+
48+
[[tool.mypy.overrides]]
49+
module = "tests.*.*"
50+
disallow_untyped_defs = false
51+
52+
[[tool.mypy.overrides]]
53+
module = "url_matcher"
54+
ignore_missing_imports = true

tests/normalizer/test_normalizer.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def test_normalizer_main_rules():
8+
assert RULE_PATHS is not None
89
rule_path = [path for path in RULE_PATHS if path.endswith("normalizer/main.json")]
910
assert len(rule_path) == 1
1011

tests/queryRemovalExcept/test_query_removal_except.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def test_query_removal_except_product_rules():
8+
assert RULE_PATHS is not None
89
rule_path = [
910
path for path in RULE_PATHS if path.endswith("queryRemovalExcept/product.json")
1011
]

tests/subpathRemoval/test_subpath_removal.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def test_subpath_removal_product_rules():
8+
assert RULE_PATHS is not None
89
rule_path = [
910
path for path in RULE_PATHS if path.endswith("subpathRemoval/product.json")
1011
]

tests/test_rules.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
def test_rule_validity():
14+
assert RULE_PATHS is not None
1415
for path in RULE_PATHS:
1516
try:
1617
with open(path, "r") as f:
@@ -45,6 +46,7 @@ def test_rule_validity():
4546

4647

4748
def test_rules_concat():
49+
assert RULE_PATHS is not None
4850
all_rules = RULE_PATHS_COMMON + RULE_PATHS_ARTICLE + RULE_PATHS_PRODUCT
4951
assert isinstance(all_rules, list)
5052
for path in all_rules:

tox.ini

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py39,py310,py311,py312,py313,linters,twine-check
2+
envlist = py39,py310,py311,py312,py313,linters,mypy,twine-check
33

44
[testenv]
55
deps =
@@ -15,6 +15,12 @@ commands =
1515
deps = pre-commit
1616
commands = pre-commit run --all-files --show-diff-on-failure
1717

18+
[testenv:mypy]
19+
deps =
20+
mypy==1.13.0
21+
duplicate-url-discarder
22+
commands = mypy duplicate_url_discarder_rules tests
23+
1824
[testenv:twine-check]
1925
deps =
2026
build

0 commit comments

Comments
 (0)