Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Properly use proper subtyping for callables#16343

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ilevkivskyi merged 1 commit intopython:masterfromilevkivskyi:fix-any-callable
Oct 27, 2023

Conversation

@ilevkivskyi
Copy link
Member

Fixes#16338

This is kind of a major change, but it is technically correct: we should not treat(*args: Any, **kwargs: Any) special inis_proper_subtype() (only inis_subtype()). Unfortunately, this requires an additional flag foris_callable_compatible(), since currently we are passing the subtype kind information via a callback, which is not applicable to handling argument kinds.

@github-actions
Copy link
Contributor

Diff frommypy_primer, showing the effect of this PR on open source code:

porcupine (https://github.com/Akuli/porcupine): typechecking got 1.41x slower (30.7s -> 43.3s)(Performance measurements are based on a single noisy sample)comtypes (https://github.com/enthought/comtypes)+ comtypes/client/_events.py:116: error: All conditional function variants must have identical signatures  [misc]+ comtypes/client/_events.py:116: note: Original:+ comtypes/client/_events.py:116: note:     def error_printer(self: Any, this: Any, *args: Any, **kw: Any) -> Any+ comtypes/client/_events.py:116: note: Redefinition:+ comtypes/client/_events.py:116: note:     def error_printer(*args: Any, **kw: Any) -> Anydiscord.py (https://github.com/Rapptz/discord.py)- discord/app_commands/commands.py:2381: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__"  [union-attr]+ discord/app_commands/commands.py:2381: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], Member], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], User], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], Message], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__"  [union-attr]- discord/app_commands/commands.py:2383: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__"  [union-attr]+ discord/app_commands/commands.py:2383: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], Member], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], User], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], Message], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__"  [union-attr]

Copy link
Collaborator

@JukkaLJukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Again, thanks for the quick fix! It's interesting that this wasn't noticed earlier.

The impact doesn't look huge based on mypy_primer, though can you have a look at the output fromcomtypes before merging?

Copy link
Collaborator

@hauntsaninjahauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

comtypes primer hit looks correct,reveal_type(func(spam)) in the test changing seems a little unfortunate

@ilevkivskyi
Copy link
MemberAuthor

Yes, the new error inmypy_primer is correct.

@hauntsaninja TheAny in overload test actually doesn't worry me. This is quite a weird test, if you look at the commit history for this test, you will see something changes there quite often. TBH I am not even sure what this test is supposed to test, and what is a desired result there.

hauntsaninja reacted with thumbs up emoji

@ilevkivskyiilevkivskyi merged commit5c6ca5c intopython:masterOct 27, 2023
@ilevkivskyiilevkivskyi deleted the fix-any-callable branchOctober 27, 2023 22:58
AlexWaygood added a commit to AlexWaygood/mypy that referenced this pull requestOct 27, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JukkaLJukkaLJukkaL approved these changes

@hauntsaninjahauntsaninjahauntsaninja approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Regression: false positive about overload item never being matched

3 participants

@ilevkivskyi@JukkaL@hauntsaninja

[8]ページ先頭

©2009-2025 Movatter.jp