Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/0.refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused dead code identified by static analysis.
3 changes: 0 additions & 3 deletions src/pdm/cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<default>[^}]*))?\}")
RE_PDM_PLACEHOLDER = re.compile(r"\{pdm\}")

Expand Down
6 changes: 0 additions & 6 deletions src/pdm/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions src/pdm/installers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 1 addition & 27 deletions src/pdm/models/project_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/pdm/models/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 0 additions & 2 deletions src/pdm/models/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Version:
focused on supporting PEP 440 version identifiers, not specifiers.
"""

MIN: Version
MAX: Version
Comment on lines -29 to -30

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep this

# Pre-release may follow version with {a|b|rc}N
# https://docs.python.org/3/faq/general.html#how-does-the-python-version-numbering-scheme-work
pre: tuple[str, int] | None = None
Expand Down
2 changes: 0 additions & 2 deletions src/pdm/project/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import itertools
import operator
import os
import re
import shutil
import sys
from copy import deepcopy
Expand Down Expand Up @@ -70,7 +69,6 @@ class Project:
"""

PYPROJECT_FILENAME = "pyproject.toml"
DEPENDENCIES_RE = re.compile(r"(?:(.+?)-)?dependencies")

def __init__(
self,
Expand Down
5 changes: 0 additions & 5 deletions src/pdm/termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down