-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update Unused
parameters in stubs/
#9704
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
Update Unused
parameters in stubs/
#9704
Conversation
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
@@ -41,7 +41,7 @@ class NoValue: | |||
def __getattr__(self, attr) -> None: ... | |||
# def __new__.<locals>.getPlug.<locals>.plug | |||
@type_check_only | |||
def plug(self, *args: object, **kw: object): ... | |||
def plug(self, *args: Unused, **kw: Unused) -> 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.
I'm not sure I understand why this method is in the stub at all.
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.
Pretty sure it's just to use as an alias below. Source: https://github.com/pyasn1/pyasn1/blob/main/pyasn1/type/base.py#L212 (which the comment also point to being defined in the function getPlug
in the function __new__
)
def __delitem__(self, *arg: Unused, **kw: Unused) -> NoReturn: ... | ||
def __setitem__(self, *arg: Unused, **kw: Unused) -> NoReturn: ... | ||
def __setattr__(self, *arg: Unused, **kw: Unused) -> 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.
(I haven't looked at the source code here, just speculating.)
If instances of ImmutableContainer
are meant to be, well, immutable, it might produce better type checking if we just omitted these methods from the stub altogether.
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.
Maybe relevant to your question:
microsoft/pyright#4653 (comment)
python/mypy#14726
Follow-up to #9519 for third-party stubs now that a new version of mypy has been released
Ref #9297
Avoids touching
__a?exit__
. That's in #9696Three steps:
Unused
instead of_Unused
object | None
toobject
(unless there's a helpful reason for it, in which case a comment was added)object
to be typed withUnused