Skip to content

Commit

Permalink
chore(mypy): use newly available unused-ignore error code
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Jun 20, 2023
1 parent a550de2 commit c98fd4a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion deptry/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _get_stdlib_modules() -> frozenset[str]:
if sys.version_info[:2] >= (3, 10):
return sys.stdlib_module_names

try: # type: ignore[unreachable]
try: # type: ignore[unreachable, unused-ignore]
return STDLIBS_PYTHON[f"{sys.version_info[0]}{sys.version_info[1]}"]
except KeyError as e:
raise UnsupportedPythonVersionError((sys.version_info[0], sys.version_info[1])) from e
Expand Down
10 changes: 0 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ warn_unreachable = true
pretty = true
show_error_codes = true

# Ignore warnings for unused ignores because of https://github.com/python/mypy/issues/8823.
# In some Python versions, we can end up with backport modules being untyped, while they are typed on others.
[[tool.mypy.overrides]]
module = [
"deptry.core",
"scripts.generate_stdlibs",
"tests.unit.test_core",
]
warn_unused_ignores = false

[tool.deptry]
extend_exclude = [
"docs",
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_stdlibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def write_stdlibs_file(stdlib_python: dict[str, list[str]]) -> None:
)

with OUTPUT_PATH.open("w+") as stdlib_file:
stdlib_file.write(ast.unparse(node)) # type: ignore[attr-defined]
stdlib_file.write(ast.unparse(node)) # type: ignore[attr-defined, unused-ignore]


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test__get_stdlib_packages_without_stdlib_module_names() -> None:

@pytest.mark.skipif(sys.version_info < (3, 10), reason="only Python >= 3.10 has sys.stdlib_module_names")
def test__get_stdlib_packages_with_stdlib_module_names() -> None:
assert Core._get_stdlib_modules() == sys.stdlib_module_names # type: ignore[attr-defined]
assert Core._get_stdlib_modules() == sys.stdlib_module_names # type: ignore[attr-defined, unused-ignore]


@pytest.mark.parametrize(
Expand All @@ -123,7 +123,7 @@ def test__get_stdlib_packages_with_stdlib_module_names() -> None:
def test__get_stdlib_packages_with_stdlib_module_names_future_version(version_info: tuple[int | str, ...]) -> None:
"""Test that future versions of Python not yet tested on the CI will also work."""
with mock.patch("sys.version_info", (sys.version_info[0], sys.version_info[1] + 1, 0)):
assert Core._get_stdlib_modules() == sys.stdlib_module_names # type: ignore[attr-defined]
assert Core._get_stdlib_modules() == sys.stdlib_module_names # type: ignore[attr-defined, unused-ignore]


@pytest.mark.parametrize(
Expand Down

0 comments on commit c98fd4a

Please sign in to comment.