setuptools._distutils: spawn functions should match each other + add overload based on search_path param
#15154
+31
−9
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.