diff --git a/python/uv/_build_backend.py b/python/uv/_build_backend.py index 127342d8eea8..03fffd6d12f2 100644 --- a/python/uv/_build_backend.py +++ b/python/uv/_build_backend.py @@ -18,17 +18,20 @@ TYPE_CHECKING = False if TYPE_CHECKING: + from collections.abc import Mapping, Sequence # noqa:I001 from typing import Any # noqa:I001 -def warn_config_settings(config_settings: "dict[Any, Any] | None" = None) -> None: +def warn_config_settings(config_settings: "Mapping[Any, Any] | None" = None) -> None: import sys if config_settings: print("Warning: Config settings are not supported", file=sys.stderr) -def call(args: "list[str]", config_settings: "dict[Any, Any] | None" = None) -> str: +def call( + args: "Sequence[str]", config_settings: "Mapping[Any, Any] | None" = None +) -> str: """Invoke a uv subprocess and return the filename from stdout.""" import shutil import subprocess @@ -40,7 +43,7 @@ def call(args: "list[str]", config_settings: "dict[Any, Any] | None" = None) -> if uv_bin is None: raise RuntimeError("uv was not properly installed") # Forward stderr, capture stdout for the filename - result = subprocess.run([uv_bin] + args, stdout=subprocess.PIPE) + result = subprocess.run([uv_bin, *args], stdout=subprocess.PIPE) if result.returncode != 0: sys.exit(result.returncode) # If there was extra stdout, forward it (there should not be extra stdout) @@ -54,7 +57,7 @@ def call(args: "list[str]", config_settings: "dict[Any, Any] | None" = None) -> def build_sdist( - sdist_directory: str, config_settings: "dict[Any, Any] | None" = None + sdist_directory: str, config_settings: "Mapping[Any, Any] | None" = None ) -> str: """PEP 517 hook `build_sdist`.""" args = ["build-backend", "build-sdist", sdist_directory] @@ -63,7 +66,7 @@ def build_sdist( def build_wheel( wheel_directory: str, - config_settings: "dict[Any, Any] | None" = None, + config_settings: "Mapping[Any, Any] | None" = None, metadata_directory: "str | None" = None, ) -> str: """PEP 517 hook `build_wheel`.""" @@ -74,23 +77,23 @@ def build_wheel( def get_requires_for_build_sdist( - config_settings: "dict[Any, Any] | None" = None, -) -> "list[str]": + config_settings: "Mapping[Any, Any] | None" = None, +) -> "Sequence[str]": """PEP 517 hook `get_requires_for_build_sdist`.""" warn_config_settings(config_settings) return [] def get_requires_for_build_wheel( - config_settings: "dict[Any, Any] | None" = None, -) -> "list[str]": + config_settings: "Mapping[Any, Any] | None" = None, +) -> "Sequence[str]": """PEP 517 hook `get_requires_for_build_wheel`.""" warn_config_settings(config_settings) return [] def prepare_metadata_for_build_wheel( - metadata_directory: str, config_settings: "dict[Any, Any] | None" = None + metadata_directory: str, config_settings: "Mapping[Any, Any] | None" = None ) -> str: """PEP 517 hook `prepare_metadata_for_build_wheel`.""" args = ["build-backend", "prepare-metadata-for-build-wheel", metadata_directory] @@ -99,7 +102,7 @@ def prepare_metadata_for_build_wheel( def build_editable( wheel_directory: str, - config_settings: "dict[Any, Any] | None" = None, + config_settings: "Mapping[Any, Any] | None" = None, metadata_directory: "str | None" = None, ) -> str: """PEP 660 hook `build_editable`.""" @@ -110,15 +113,15 @@ def build_editable( def get_requires_for_build_editable( - config_settings: "dict[Any, Any] | None" = None, -) -> "list[str]": + config_settings: "Mapping[Any, Any] | None" = None, +) -> "Sequence[str]": """PEP 660 hook `get_requires_for_build_editable`.""" warn_config_settings(config_settings) return [] def prepare_metadata_for_build_editable( - metadata_directory: str, config_settings: "dict[Any, Any] | None" = None + metadata_directory: str, config_settings: "Mapping[Any, Any] | None" = None ) -> str: """PEP 660 hook `prepare_metadata_for_build_editable`.""" args = ["build-backend", "prepare-metadata-for-build-editable", metadata_directory]