-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make build backend type annotations more generic #10549
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,17 +18,17 @@ | |
|
||
TYPE_CHECKING = False | ||
if TYPE_CHECKING: | ||
from typing import Any # noqa:I001 | ||
from typing import Any, Mapping # 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: "list[str]", config_settings: "Mapping[Any, Any] | None" = None) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So if this wasn't intended, then you could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 7250bdb |
||
"""Invoke a uv subprocess and return the filename from stdout.""" | ||
import shutil | ||
import subprocess | ||
|
@@ -54,7 +54,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 +63,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 +74,23 @@ def build_wheel( | |
|
||
|
||
def get_requires_for_build_sdist( | ||
config_settings: "dict[Any, Any] | None" = None, | ||
config_settings: "Mapping[Any, Any] | None" = None, | ||
) -> "list[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, | ||
config_settings: "Mapping[Any, Any] | None" = None, | ||
) -> "list[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 +99,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 +110,15 @@ def build_editable( | |
|
||
|
||
def get_requires_for_build_editable( | ||
config_settings: "dict[Any, Any] | None" = None, | ||
config_settings: "Mapping[Any, Any] | None" = None, | ||
) -> "list[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] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typing.Mapping
is deprecated since python 3.9, so it's recommended to import it fromcollections.abc
: https://docs.python.org/3/library/typing.html#typing.MappingAnd it apparently already works on Python 3.8:
https://basedpyright.com/?pythonVersion=3.8&typeCheckingMode=all&code=GYJw9gtgBAxmA28CmMAuBLMA7AzgOgEMAjGKdCABzBFSgFkCKL0sBzAWACguCAuexszYBtHKhAAaKGJABdKAF4oAbwC%2BXIA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also checked on PyPI, and the uv python package only supports py38+, so this is doable. Updated in 808eb2d.