-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix pos-only params in os
module
#11505
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.
def execl(file: StrOrBytesPath, *args: Unpack[tuple[StrOrBytesPath, Unpack[tuple[StrOrBytesPath, ...]]]]) -> NoReturn: ... | ||
def execlp(file: StrOrBytesPath, *args: Unpack[tuple[StrOrBytesPath, Unpack[tuple[StrOrBytesPath, ...]]]]) -> NoReturn: ... |
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.
Using PEP646 feels unnecessarily complicated here (and e.g. pytype still doesn't support PEP646 -- it just falls back to Any
when it sees Unpack
, I believe). Can't we just do this?
def execl(file: StrOrBytesPath, *args: Unpack[tuple[StrOrBytesPath, Unpack[tuple[StrOrBytesPath, ...]]]]) -> NoReturn: ... | |
def execlp(file: StrOrBytesPath, *args: Unpack[tuple[StrOrBytesPath, Unpack[tuple[StrOrBytesPath, ...]]]]) -> NoReturn: ... | |
def execl(file: StrOrBytesPath, arg0: StrOrBytesPath, /, *args: StrOrBytesPath) -> NoReturn: ... | |
def execlp(file: StrOrBytesPath, arg0: StrOrBytesPath, /, *args: StrOrBytesPath) -> NoReturn: ... |
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.
Yes, looks easier!
Co-authored-by: Alex Waygood <[email protected]>
Oh interesting. Stubtest is correct; you really can pass >>> import os
>>> os.execl(file='foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen os>", line 548, in execl
ValueError: execv() arg 2 must not be empty |
Hm, this way we have a stubtest problem:
|
This comment has been minimized.
This comment has been minimized.
I guess your PEP646 way is the best way, in that case :) |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Problem:
It is the same notation for
__arg1: X, *args: X
Link: https://mypy-play.net/?mypy=latest&python=3.12&gist=b35729b668bf88a0d98a78a8d37c5be1