-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update asyncio subprocess optional **kwargs. #9177
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
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
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.
These kwargs are delegated to subprocess.Popen
, so it would be good to match the types exactly. It seems that 3.11 added another new kwarg, process_group: int | None = ...
, so we should add a 3.11 branch to these stubs too.
pass_fds
is Any in stdlib/subprocess.pyi
, but from looking at the code Iterable[int]
does appear to be the right type. Feel free to fix that type in this PR too.
@JelleZijlstra done |
This comment has been minimized.
This comment has been minimized.
subprocess.py: fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self.pid = _posixsubprocess.fork_exec(
args, executable_list,
close_fds, tuple(sorted(map(int, fds_to_keep))), Documentation: https://docs.python.org/3/library/subprocess.html
Yes, it's allowed to pass non-int. But I think it's a bug to pass non-int. pypeeter code: options = dict()
options['env'] = self.env
if not self.dumpio:
# discard stdout, it's never read in any case.
options['stdout'] = subprocess.DEVNULL
options['stderr'] = subprocess.STDOUT
self.proc = subprocess.Popen( # type: ignore
self.cmd, **options, ) |
Since |
This comment has been minimized.
This comment has been minimized.
The new error seems correct, though maybe mypy should listen to the type ignore: https://github.com/pyppeteer/pyppeteer/blob/7245ee0bccd97d43e45b801319dd6cbae860292a/pyppeteer/launcher.py#L148 |
stdlib/asyncio/subprocess.pyi
Outdated
extra_groups: None | Collection[str | int] = ..., | ||
user: None | str | int = ..., | ||
umask: int = ..., | ||
process_group: str | int | None = ..., |
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.
subprocess has this as just int | None
, which looks correct based on the C code.
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 dont' understand what you wanted to say.
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.
In subprocess.pyi
, the type of the process_group
parameter is int | None
, not str | int | None
. Based on my reading of the relevant C code, int | None
appears to be correct.
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.
@socketpair, you haven't addressed this comment here. Jelle is asking you to change the annotation for the process_group
parameter (both for this function and all other functions that have this parameter) to be int | None
instead of str | int | None
. You need to either make the change or explain why you think that this would be incorrect.
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.
Really. it's my bug. Will fix in next commit.
What should I do to move this PR to merging ? |
@JelleZijlstra done |
I'm not seeing the change, did you forget to push? |
@JelleZijlstra sorry for calling again. What should I change (what is wrong) in current PR? Please mark these changes somehow in order to distinguish from just speaking. Now, I will just rebase, no other changes. |
This comment has been minimized.
This comment has been minimized.
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.
Requesting changes until #9177 (comment) is addressed
I don't understand new Github review semantics. I just changed what you requested. I don't know if I need to tap something in GH |
Diff from mypy_primer, showing the effect of this PR on open source code: pyppeteer (https://github.com/pyppeteer/pyppeteer)
+ pyppeteer/launcher.py:149: error: Argument 2 to "Popen" has incompatible type "**Dict[str, Optional[Any]]"; expected "Collection[int]" [arg-type]
|
Made strongly according to documentation (possible Sequence vs Iterable vs Collection bug).
But did not check.