Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Feb 22, 2023

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Feb 10, 2023

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 #9696

Three steps:

  1. Use Unused instead of _Unused
  2. Update some stray object | None to object (unless there's a helpful reason for it, in which case a comment was added)
  3. Change unused parameters typed as object to be typed with Unused

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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: ...
Copy link
Member

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.

Copy link
Collaborator Author

@Avasam Avasam Feb 22, 2023

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__)

@JelleZijlstra JelleZijlstra merged commit 078c6a0 into python:main Feb 22, 2023
Comment on lines +19 to +21
def __delitem__(self, *arg: Unused, **kw: Unused) -> NoReturn: ...
def __setitem__(self, *arg: Unused, **kw: Unused) -> NoReturn: ...
def __setattr__(self, *arg: Unused, **kw: Unused) -> NoReturn: ...
Copy link
Member

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.

Copy link
Collaborator Author

@Avasam Avasam Feb 22, 2023

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

@Avasam Avasam deleted the Update-Unused-parameters-in-stubs branch February 22, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants