diff --git a/src/pdm/backend/base.py b/src/pdm/backend/base.py index 0487f43..7a18082 100644 --- a/src/pdm/backend/base.py +++ b/src/pdm/backend/base.py @@ -7,7 +7,15 @@ import warnings from fnmatch import fnmatch from pathlib import Path -from typing import TYPE_CHECKING, Any, Iterable, Mapping, TypeVar, cast +from typing import ( + TYPE_CHECKING, + Any, + Iterable, + Literal, + Mapping, + TypeVar, + cast, +) from pdm.backend.config import Config from pdm.backend.exceptions import PDMWarning, ValidationError @@ -81,12 +89,15 @@ def _find_top_packages(root: str) -> list[str]: return result +Target = Literal["sdist", "wheel", "editable"] + + class Builder: """Base class for building and distributing a package from given path.""" DEFAULT_EXCLUDES = [".pdm-build"] - target: str + target: Target hooks: list[BuildHookInterface] = [DynamicVersionBuildHook()] def __init__( diff --git a/src/pdm/backend/hooks/base.py b/src/pdm/backend/hooks/base.py index 1eaff20..6d64f92 100644 --- a/src/pdm/backend/hooks/base.py +++ b/src/pdm/backend/hooks/base.py @@ -9,7 +9,7 @@ if TYPE_CHECKING: from typing import Protocol - from pdm.backend.base import Builder + from pdm.backend.base import Builder, Target else: Protocol = object @@ -44,7 +44,7 @@ def root(self) -> Path: return self.builder.location @property - def target(self) -> str: + def target(self) -> Target: """The target to build, one of 'sdist', 'wheel', 'editable'""" return self.builder.target