From b345e364a3159f6d7f12f3e03f602c12d5ea74b0 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Sat, 28 Sep 2024 19:50:36 +0200 Subject: [PATCH] chore: run `pre-commit run -a` --- python/deptry/dependency_getter/builder.py | 3 ++- python/deptry/violations/finder.py | 2 +- tests/unit/dependency_getter/test_builder.py | 14 +++++++++----- tests/unit/test_core.py | 11 +++++++---- tests/utils.py | 3 ++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/python/deptry/dependency_getter/builder.py b/python/deptry/dependency_getter/builder.py index 42c6cdcf..2cdfbfd8 100644 --- a/python/deptry/dependency_getter/builder.py +++ b/python/deptry/dependency_getter/builder.py @@ -1,9 +1,10 @@ from __future__ import annotations import logging +from collections.abc import Mapping from dataclasses import dataclass, field from pathlib import Path -from typing import TYPE_CHECKING, Mapping +from typing import TYPE_CHECKING from deptry.dependency_getter.pep621.base import PEP621DependencyGetter from deptry.dependency_getter.pep621.pdm import PDMDependencyGetter diff --git a/python/deptry/violations/finder.py b/python/deptry/violations/finder.py index 6311f9d1..286a39a0 100644 --- a/python/deptry/violations/finder.py +++ b/python/deptry/violations/finder.py @@ -12,7 +12,7 @@ ) if TYPE_CHECKING: - from typing import Mapping + from collections.abc import Mapping from deptry.dependency import Dependency from deptry.module import ModuleLocations diff --git a/tests/unit/dependency_getter/test_builder.py b/tests/unit/dependency_getter/test_builder.py index e4ce7ea5..b30c4a31 100644 --- a/tests/unit/dependency_getter/test_builder.py +++ b/tests/unit/dependency_getter/test_builder.py @@ -136,11 +136,15 @@ def test_dependency_specification_not_found_raises_exception(tmp_path: Path, cap with pyproject_toml_path.open("w") as f: f.write('[build-system]\nrequires = ["maturin>=1.5,<2.0"]\nbuild-backend = "maturin"') - with caplog.at_level(logging.DEBUG), run_within_dir(tmp_path), pytest.raises( - DependencySpecificationNotFoundError, - match=re.escape( - "No file called 'pyproject.toml' with a [tool.poetry.dependencies], [tool.pdm] or [project] section or" - " file(s) called 'req/req.txt' found. Exiting." + with ( + caplog.at_level(logging.DEBUG), + run_within_dir(tmp_path), + pytest.raises( + DependencySpecificationNotFoundError, + match=re.escape( + "No file called 'pyproject.toml' with a [tool.poetry.dependencies], [tool.pdm] or [project] section or" + " file(s) called 'req/req.txt' found. Exiting." + ), ), ): DependencyGetterBuilder(Path("pyproject.toml"), requirements_files=("req/req.txt",)).build() diff --git a/tests/unit/test_core.py b/tests/unit/test_core.py index 9b2437e8..626f5a6a 100644 --- a/tests/unit/test_core.py +++ b/tests/unit/test_core.py @@ -174,10 +174,13 @@ def test__get_stdlib_packages_with_stdlib_module_names_future_version(version_in ) def test__get_stdlib_packages_unsupported(version_info: tuple[int | str, ...]) -> None: """It should raise an error when Python version is unsupported.""" - with mock.patch("sys.version_info", version_info), pytest.raises( - UnsupportedPythonVersionError, - match=re.escape( - f"Python version {version_info[0]}.{version_info[1]} is not supported. Only versions >= 3.9 are supported." + with ( + mock.patch("sys.version_info", version_info), + pytest.raises( + UnsupportedPythonVersionError, + match=re.escape( + f"Python version {version_info[0]}.{version_info[1]} is not supported. Only versions >= 3.9 are supported." + ), ), ): Core._get_standard_library_modules() diff --git a/tests/utils.py b/tests/utils.py index 548b90bf..52860c1b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -7,10 +7,11 @@ import subprocess import sys import venv +from collections.abc import Generator from contextlib import contextmanager from dataclasses import dataclass from pathlib import Path -from typing import Any, Generator +from typing import Any from deptry.reporters.text import COLORS from tests.functional.utils import DEPTRY_WHEEL_DIRECTORY