Skip to content

Commit

Permalink
chore: run pre-commit run -a
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Sep 28, 2024
1 parent a1b1f03 commit b345e36
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion python/deptry/dependency_getter/builder.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/deptry/violations/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions tests/unit/dependency_getter/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b345e36

Please sign in to comment.