Skip to content

Commit

Permalink
Drop support for python 3.8 (#444)
Browse files Browse the repository at this point in the history
Drops support for python 3.8 since it is EOL. The code refactoring is
due to ruff's formatting rules for 3.9.
  • Loading branch information
kemzeb authored Jan 26, 2025
1 parent 8218e8c commit 99cdda2
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 21 deletions.
1 change: 0 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- type
- dev
- pkg_meta
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ maintainers = [
{ name = "Bernát Gábor", email = "[email protected]" },
{ name = "Vineet Naik", email = "[email protected]" },
]
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/pipdeptree/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand Down
5 changes: 4 additions & 1 deletion src/pipdeptree/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/pipdeptree/_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/pipdeptree/_models/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/pipdeptree/_models/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
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

from pipdeptree._freeze import dist_to_frozen_repr

if TYPE_CHECKING:
from collections.abc import Iterator
from importlib.metadata import Distribution


Expand Down
3 changes: 2 additions & 1 deletion tests/_models/test_dag.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
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

from pipdeptree._models import PackageDAG

if TYPE_CHECKING:
from collections.abc import Iterator

from tests.our_types import MockGraph


Expand Down
4 changes: 1 addition & 3 deletions tests/our_types.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tests/render/test_json_tree.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Iterator
from typing import TYPE_CHECKING, Callable

import pytest

from pipdeptree._models.dag import PackageDAG
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
Expand Down
3 changes: 2 additions & 1 deletion tests/render/test_mermaid.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/render/test_text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Iterator
from typing import TYPE_CHECKING, Callable

import pytest

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/test_validate.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Iterator
from typing import TYPE_CHECKING, Callable

import pytest

from pipdeptree._models import PackageDAG
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
Expand Down
1 change: 0 additions & 1 deletion tox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ env_list = [
"3.11",
"3.10",
"3.9",
"3.8",
"type",
"pkg_meta",
]
Expand Down

0 comments on commit 99cdda2

Please sign in to comment.