setuptools._distutils: spawn functions should match each other + add overload based on search_path param#15154
Merged
srittau merged 5 commits intopython:mainfrom Dec 20, 2025
Conversation
177b1d7 to
b0b1402
Compare
search_path paramsetuptools._distutils: spawn functions should match each other + add overload based on search_path param
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
srittau
approved these changes
Dec 20, 2025
Collaborator
srittau
left a comment
There was a problem hiding this comment.
LGTM, although I would consider leaving out the unused arguments as a hint to the user that the argument probably doesn't do what they think it does. Whichever you prefer.
Collaborator
Author
I've considered doing that as well upstream. If you're also mentioning it, I think it's worth omitting the unused keyword-only arguments |
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: pywin32 (https://github.com/mhammond/pywin32)
+ setup.py:918: error: Unused "type: ignore" comment [unused-ignore]
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Noticed in mhammond/pywin32#2697
Upstream equivalent: pypa/distutils#390
As a reminder, here's the type restrictions for
spawn:subprocess.check_call's first argument is typed as_CMDwhich is an alias forStrOrBytesPath | Sequence[StrOrBytesPath]search_path=True:shutil.which, so cannot be aBytesPathcmd: StrOrBytesPathcould work, but is not part of the intended api, and will result in incorrect error messages on failures (where the first element is what's included in the message if not in debug mode)I'm aware that
MutableSequenceis invariant, but I believe that most usages ofspawnwill either be a string/tuple literal (which at least pyright will allow a partial union match on invariant generics, idk about mypy though). And that otherwise explicitly marking one's variable as such is easy enough:cmd: list[bytes | StrPath] = ["my", "cmd"]. This is already an issue in existing stub anyway and pypa/distutils#390 will try to address that upstream.