-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
distutils
& setuptools
: Relax path related params
#11948
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
Merged
JelleZijlstra
merged 10 commits into
python:main
from
Avasam:distutils-relax-path-params
May 21, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8206337
`distutils`: Relax path params
Avasam 9048443
Fix typos
Avasam 95990bf
wrong import
Avasam e8d6984
Merge branch 'main' into distutils-relax-path-params
JelleZijlstra cb866fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b02dc75
Update dep_util
Avasam 61c0ea5
Merge branch 'main' of https://github.com/python/typeshed into distut…
Avasam 59e23f5
Remove unused allowlist entry
Avasam dd18995
Address PR comments and improve newer_pairwise
Avasam d52befb
Merge branch 'main' of https://github.com/python/typeshed into distut…
Avasam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
def newer(source: str, target: str) -> bool: ... | ||
def newer_pairwise(sources: list[str], targets: list[str]) -> list[tuple[str, str]]: ... | ||
def newer_group(sources: list[str], target: str, missing: str = "error") -> bool: ... | ||
from _typeshed import StrOrBytesPath, SupportsLenAndGetItem | ||
from collections.abc import Iterable | ||
from typing import Literal, TypeVar | ||
|
||
_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) | ||
_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) | ||
|
||
def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool | Literal[1]: ... | ||
def newer_pairwise( | ||
sources: SupportsLenAndGetItem[_SourcesT], targets: SupportsLenAndGetItem[_TargetsT] | ||
) -> tuple[list[_SourcesT], list[_TargetsT]]: ... | ||
def newer_group( | ||
sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" | ||
) -> Literal[0, 1]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
from collections.abc import Sequence | ||
from typing import Literal | ||
from _typeshed import BytesPath, StrOrBytesPath, StrPath | ||
from collections.abc import Iterable | ||
from typing import Literal, TypeVar, overload | ||
|
||
_StrPathT = TypeVar("_StrPathT", bound=StrPath) | ||
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) | ||
|
||
@overload | ||
def copy_file( | ||
src: StrPath, | ||
dst: _StrPathT, | ||
preserve_mode: bool | Literal[0, 1] = 1, | ||
preserve_times: bool | Literal[0, 1] = 1, | ||
update: bool | Literal[0, 1] = 0, | ||
link: str | None = None, | ||
verbose: bool | Literal[0, 1] = 1, | ||
dry_run: bool | Literal[0, 1] = 0, | ||
) -> tuple[_StrPathT | str, bool]: ... | ||
@overload | ||
def copy_file( | ||
src: str, | ||
dst: str, | ||
src: BytesPath, | ||
dst: _BytesPathT, | ||
preserve_mode: bool | Literal[0, 1] = 1, | ||
preserve_times: bool | Literal[0, 1] = 1, | ||
update: bool | Literal[0, 1] = 0, | ||
link: str | None = None, | ||
verbose: bool | Literal[0, 1] = 1, | ||
dry_run: bool | Literal[0, 1] = 0, | ||
) -> tuple[str, str]: ... | ||
def move_file(src: str, dst: str, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0) -> str: ... | ||
def write_file(filename: str, contents: Sequence[str]) -> None: ... | ||
) -> tuple[_BytesPathT | bytes, bool]: ... | ||
@overload | ||
def move_file( | ||
src: StrPath, dst: _StrPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 | ||
) -> _StrPathT | str: ... | ||
@overload | ||
def move_file( | ||
src: BytesPath, dst: _BytesPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 | ||
) -> _BytesPathT | bytes: ... | ||
def write_file(filename: StrOrBytesPath, contents: Iterable[str]) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
from typing import Literal | ||
from _typeshed import StrOrBytesPath | ||
from collections.abc import Callable, Iterable | ||
from typing import Literal, TypeVar | ||
|
||
def newer(source, target): ... | ||
def newer_pairwise(sources, targets, newer=...): ... | ||
def newer_group(sources, target, missing: Literal["error", "newer", "ignore"] = "error"): ... | ||
def newer_pairwise_group(sources, targets, *, newer=...): ... | ||
_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) | ||
_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) | ||
|
||
def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool: ... | ||
def newer_pairwise( | ||
sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], newer: Callable[[_SourcesT, _TargetsT], bool] = ... | ||
) -> tuple[list[_SourcesT], list[_TargetsT]]: ... | ||
def newer_group( | ||
sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" | ||
) -> bool: ... | ||
def newer_pairwise_group( | ||
sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], *, newer: Callable[[_SourcesT, _TargetsT], bool] = ... | ||
) -> tuple[list[_SourcesT], list[_TargetsT]]: ... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need these overloads? Looks like only
base_name
androot_dir
are different, and when I look at the implementation in 3.11, I don't see any interdependency between those.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.
If
root_dir
is notNone
,base_name
can bePathLike[str]
https://github.com/python/cpython/blob/v3.11.9/Lib/distutils/archive_util.py#L225-L227
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 see. I'm not enthusiastic about adding overloads for cases like this where some types work by accident depending on the path taken through the body of the function.