diff --git a/news/0.refactor.md b/news/0.refactor.md new file mode 100644 index 0000000000..f9ec0c4d99 --- /dev/null +++ b/news/0.refactor.md @@ -0,0 +1 @@ +Remove unused dead code identified by static analysis. diff --git a/src/pdm/cli/commands/run.py b/src/pdm/cli/commands/run.py index 234e6fcee7..d90a275345 100644 --- a/src/pdm/cli/commands/run.py +++ b/src/pdm/cli/commands/run.py @@ -54,9 +54,6 @@ def merge_options(*options: TaskOptions | None) -> TaskOptions: ) -exec_opts = merge_options # Alias for merge_options - - RE_ARGS_PLACEHOLDER = re.compile(r"\{args(?::(?P[^}]*))?\}") RE_PDM_PLACEHOLDER = re.compile(r"\{pdm\}") diff --git a/src/pdm/exceptions.py b/src/pdm/exceptions.py index b50731538b..87bcea8d7e 100644 --- a/src/pdm/exceptions.py +++ b/src/pdm/exceptions.py @@ -61,12 +61,6 @@ class PDMDeprecationWarning(PDMWarning, DeprecationWarning): warnings.simplefilter("default", category=PDMDeprecationWarning) -class ExtrasWarning(PDMWarning): - def __init__(self, project_name: str, extras: list[str]) -> None: - super().__init__(f"Extras not found for {project_name}: [{','.join(extras)}]") - self.extras = tuple(extras) - - class ProjectError(PdmUsageError): pass diff --git a/src/pdm/installers/manager.py b/src/pdm/installers/manager.py index 2946ab82c4..f1fb1fc503 100644 --- a/src/pdm/installers/manager.py +++ b/src/pdm/installers/manager.py @@ -16,9 +16,6 @@ class InstallManager: """The manager that performs the installation and uninstallation actions.""" - # The packages below are needed to load paths and thus should not be cached. - NO_CACHE_PACKAGES = ("editables",) - def __init__( self, environment: BaseEnvironment, *, use_install_cache: bool = False, rename_pth: bool = False ) -> None: diff --git a/src/pdm/models/project_info.py b/src/pdm/models/project_info.py index cea936c576..f81e29c4ad 100644 --- a/src/pdm/models/project_info.py +++ b/src/pdm/models/project_info.py @@ -3,15 +3,12 @@ import itertools from dataclasses import dataclass, field from email.message import Message -from typing import TYPE_CHECKING, Any, Iterator, cast +from typing import TYPE_CHECKING, Iterator, cast if TYPE_CHECKING: from pdm.compat import Distribution -DYNAMIC = "DYNAMIC" - - @dataclass class ProjectInfo: name: str @@ -55,29 +52,6 @@ def from_distribution(cls, data: Distribution) -> ProjectInfo: project_urls=[": ".join(parts) for parts in project_urls.items()], ) - @classmethod - def from_metadata(cls, metadata: dict[str, Any]) -> ProjectInfo: - def get_str(key: str) -> str: - if key in metadata.get("dynamic", []): - return DYNAMIC - return metadata.get(key, "") - - authors = metadata.get("authors", []) - author = authors[0]["name"] if authors else "" - email = authors[0]["email"] if authors else "" - - return cls( - name=metadata["name"], - version=get_str("version"), - summary=get_str("description"), - author=author, - email=email, - license=metadata.get("license", {}).get("text", ""), - requires_python=get_str("requires-python"), - keywords=",".join(get_str("keywords")), - project_urls=[": ".join(parts) for parts in metadata.get("urls", {}).items()], - ) - def generate_rows(self) -> Iterator[tuple[str, str]]: yield "[primary]Name[/]:", self.name yield "[primary]Latest version[/]:", self.version diff --git a/src/pdm/models/specifiers.py b/src/pdm/models/specifiers.py index c7eb4b98ec..a93b7d1ac3 100644 --- a/src/pdm/models/specifiers.py +++ b/src/pdm/models/specifiers.py @@ -72,7 +72,6 @@ class PySpecSet(SpecifierSet): """A custom SpecifierSet that supports merging with logic operators (&, |).""" PY_MAX_MINOR_VERSION = _read_max_versions() - MAX_MAJOR_VERSION = max(PY_MAX_MINOR_VERSION)[:1].bump() __slots__ = ("_logic", "_prereleases", "_specs") diff --git a/src/pdm/project/core.py b/src/pdm/project/core.py index dfc4c5d15c..8e949a0c96 100644 --- a/src/pdm/project/core.py +++ b/src/pdm/project/core.py @@ -5,7 +5,6 @@ import itertools import operator import os -import re import shutil import sys from copy import deepcopy @@ -70,7 +69,6 @@ class Project: """ PYPROJECT_FILENAME = "pyproject.toml" - DEPENDENCIES_RE = re.compile(r"(?:(.+?)-)?dependencies") def __init__( self, diff --git a/src/pdm/termui.py b/src/pdm/termui.py index f7c2be67e7..bd538313de 100644 --- a/src/pdm/termui.py +++ b/src/pdm/termui.py @@ -155,11 +155,6 @@ def __exit__(self, *args: Any) -> None: pass -class SilentSpinner(DummySpinner): - def _show(self) -> None: - pass - - class TruncatedIO: """A wrapper for IO that truncates output after certain length."""