Skip to content

Commit

Permalink
Add mypy.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Nov 4, 2024
1 parent 68a40a3 commit 11d565a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion duplicate_url_discarder_rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/normalizer/test_normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/queryRemovalExcept/test_query_removal_except.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
Expand Down
1 change: 1 addition & 0 deletions tests/subpathRemoval/test_subpath_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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
Expand Down

0 comments on commit 11d565a

Please sign in to comment.