diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 6aaad88e..a0564255 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -26,7 +26,6 @@ jobs: - "3.11" - "3.10" - "3.9" - - "3.8" - type - dev - pkg_meta diff --git a/pyproject.toml b/pyproject.toml index 6dd3e820..c2d13bbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ maintainers = [ { name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }, { name = "Vineet Naik", email = "naikvin@gmail.com" }, ] -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", @@ -30,7 +30,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -68,7 +67,6 @@ build.hooks.vcs.version-file = "src/pipdeptree/version.py" version.source = "vcs" [tool.ruff] -target-version = "py38" line-length = 120 format.preview = true format.docstring-code-line-length = 100 diff --git a/src/pipdeptree/__main__.py b/src/pipdeptree/__main__.py index fca21b96..ca9a9737 100644 --- a/src/pipdeptree/__main__.py +++ b/src/pipdeptree/__main__.py @@ -3,7 +3,7 @@ from __future__ import annotations import sys -from typing import Sequence +from typing import TYPE_CHECKING from pipdeptree._cli import get_options from pipdeptree._detect_env import detect_active_interpreter @@ -13,6 +13,9 @@ from pipdeptree._validate import validate from pipdeptree._warning import WarningPrinter, WarningType, get_warning_printer +if TYPE_CHECKING: + from collections.abc import Sequence + def main(args: Sequence[str] | None = None) -> int | None: """CLI - The main function called as entry point.""" diff --git a/src/pipdeptree/_cli.py b/src/pipdeptree/_cli.py index 44ebfce2..9d8f2074 100644 --- a/src/pipdeptree/_cli.py +++ b/src/pipdeptree/_cli.py @@ -3,12 +3,15 @@ import enum import sys from argparse import Action, ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace -from typing import Any, Sequence, cast +from typing import TYPE_CHECKING, Any, cast from pipdeptree._warning import WarningType from .version import __version__ +if TYPE_CHECKING: + from collections.abc import Sequence + class Options(Namespace): freeze: bool diff --git a/src/pipdeptree/_discovery.py b/src/pipdeptree/_discovery.py index ba23498a..9c19d93d 100644 --- a/src/pipdeptree/_discovery.py +++ b/src/pipdeptree/_discovery.py @@ -6,12 +6,15 @@ import sys from importlib.metadata import Distribution, distributions from pathlib import Path -from typing import Iterable, Tuple +from typing import TYPE_CHECKING from packaging.utils import canonicalize_name from pipdeptree._warning import get_warning_printer +if TYPE_CHECKING: + from collections.abc import Iterable + def get_installed_distributions( interpreter: str = str(sys.executable), @@ -103,7 +106,7 @@ def render_invalid_metadata_text(site_dirs_with_invalid_metadata: set[str]) -> N print(site_dir, file=sys.stderr) # noqa: T201 -FirstSeenWithDistsPair = Tuple[Distribution, Distribution] +FirstSeenWithDistsPair = tuple[Distribution, Distribution] def render_duplicated_dist_metadata_text( diff --git a/src/pipdeptree/_models/dag.py b/src/pipdeptree/_models/dag.py index 2f5df604..41c1cf8c 100644 --- a/src/pipdeptree/_models/dag.py +++ b/src/pipdeptree/_models/dag.py @@ -2,9 +2,10 @@ import sys from collections import defaultdict, deque +from collections.abc import Iterator, Mapping from fnmatch import fnmatch from itertools import chain -from typing import TYPE_CHECKING, Iterator, List, Mapping +from typing import TYPE_CHECKING from packaging.utils import canonicalize_name @@ -25,7 +26,7 @@ def render_invalid_reqs_text(dist_name_to_invalid_reqs_dict: dict[str, list[str] print(f' Skipping "{invalid_req}"', file=sys.stderr) # noqa: T201 -class PackageDAG(Mapping[DistPackage, List[ReqPackage]]): +class PackageDAG(Mapping[DistPackage, list[ReqPackage]]): """ Representation of Package dependencies as directed acyclic graph using a dict as the underlying datastructure. diff --git a/src/pipdeptree/_models/package.py b/src/pipdeptree/_models/package.py index 7e492506..cc3efafd 100644 --- a/src/pipdeptree/_models/package.py +++ b/src/pipdeptree/_models/package.py @@ -4,7 +4,7 @@ from importlib import import_module from importlib.metadata import Distribution, PackageNotFoundError, metadata, version from inspect import ismodule -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING from packaging.requirements import InvalidRequirement, Requirement from packaging.utils import canonicalize_name @@ -12,6 +12,7 @@ from pipdeptree._freeze import dist_to_frozen_repr if TYPE_CHECKING: + from collections.abc import Iterator from importlib.metadata import Distribution diff --git a/tests/_models/test_dag.py b/tests/_models/test_dag.py index eb909c1f..dc22cc79 100644 --- a/tests/_models/test_dag.py +++ b/tests/_models/test_dag.py @@ -1,13 +1,14 @@ from __future__ import annotations from itertools import chain -from typing import TYPE_CHECKING, Any, Callable, Iterator +from typing import TYPE_CHECKING, Any, Callable import pytest from pipdeptree._models import DistPackage, PackageDAG, ReqPackage, ReversedPackageDAG if TYPE_CHECKING: + from collections.abc import Iterator from unittest.mock import Mock from tests.our_types import MockGraph diff --git a/tests/conftest.py b/tests/conftest.py index c2ec5d68..ed839a13 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import locale from pathlib import Path from random import shuffle -from typing import TYPE_CHECKING, Callable, Iterator +from typing import TYPE_CHECKING, Callable from unittest.mock import Mock import pytest @@ -11,6 +11,8 @@ from pipdeptree._models import PackageDAG if TYPE_CHECKING: + from collections.abc import Iterator + from tests.our_types import MockGraph diff --git a/tests/our_types.py b/tests/our_types.py index f7f22978..154d3602 100644 --- a/tests/our_types.py +++ b/tests/our_types.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Tuple - -MockGraph = Dict[Tuple[str, str], List[Tuple[str, List[Tuple[str, str]]]]] +MockGraph = dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] # pragma: no cover __all__ = [ "MockGraph", diff --git a/tests/render/test_json_tree.py b/tests/render/test_json_tree.py index 32558a12..26c23169 100644 --- a/tests/render/test_json_tree.py +++ b/tests/render/test_json_tree.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Iterator +from typing import TYPE_CHECKING, Callable import pytest @@ -8,6 +8,7 @@ from pipdeptree._render.json_tree import render_json_tree if TYPE_CHECKING: + from collections.abc import Iterator from unittest.mock import Mock from tests.our_types import MockGraph diff --git a/tests/render/test_mermaid.py b/tests/render/test_mermaid.py index ec567c91..afc6f88c 100644 --- a/tests/render/test_mermaid.py +++ b/tests/render/test_mermaid.py @@ -1,12 +1,13 @@ from __future__ import annotations from textwrap import dedent, indent -from typing import TYPE_CHECKING, Callable, Iterator +from typing import TYPE_CHECKING, Callable from pipdeptree._models import PackageDAG from pipdeptree._render.mermaid import render_mermaid if TYPE_CHECKING: + from collections.abc import Iterator from unittest.mock import Mock from tests.our_types import MockGraph diff --git a/tests/render/test_text.py b/tests/render/test_text.py index 0db71a65..0a7322f1 100644 --- a/tests/render/test_text.py +++ b/tests/render/test_text.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Iterator +from typing import TYPE_CHECKING, Callable import pytest @@ -9,6 +9,7 @@ from pipdeptree._render.text import render_text if TYPE_CHECKING: + from collections.abc import Iterator from unittest.mock import Mock from tests.our_types import MockGraph diff --git a/tests/test_validate.py b/tests/test_validate.py index efb164b2..b9f2fef7 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Iterator +from typing import TYPE_CHECKING, Callable import pytest @@ -8,6 +8,7 @@ from pipdeptree._validate import conflicting_deps, cyclic_deps, render_conflicts_text, render_cycles_text, validate if TYPE_CHECKING: + from collections.abc import Iterator from unittest.mock import Mock from tests.our_types import MockGraph diff --git a/tox.toml b/tox.toml index 47d108d4..054b5475 100644 --- a/tox.toml +++ b/tox.toml @@ -6,7 +6,6 @@ env_list = [ "3.11", "3.10", "3.9", - "3.8", "type", "pkg_meta", ]