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

[match-case] fix matching againsttyping.Callable andProtocol types.#19471

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 23 commits intopython:masterfromrandolf-scholz:fix_match_callable
Oct 16, 2025

Conversation

@randolf-scholz
Copy link
Contributor

@randolf-scholzrandolf-scholz commentedJul 17, 2025
edited
Loading

Added extra logic inchecker.py:conditional_types function to deal with structural types such astyping.Callable or protocols.

new tests

  • testMatchClassPatternCallable: testscase Callable() as fn usage
  • testMatchClassPatternProtocol: testscase Proto() usage, whereProto is a Protocol
  • testMatchClassPatternCallbackProtocol: testscase Proto() usage, whereProto is a Callback-Protocol
  • testGenericAliasIsinstanceUnreachable: derived from a mypy-primer failure in mesonbuild. Tests thatisinstance(x, Proto) can produce unreachable error.
  • testGenericAliasRedundantExprCompoundIfExpr: derived from a CI failure ofpython runtest.py self of an earlier version of this PR.

modified tests

  • testOverloadOnProtocol added annotations to overload implementation, which wasn't getting checked. Added missing return. Fixed return type in second branch.

@github-actions

This comment has been minimized.

@randolf-scholzrandolf-scholz marked this pull request as draftJuly 19, 2025 22:16
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@randolf-scholzrandolf-scholz marked this pull request as ready for reviewJuly 20, 2025 10:49
@sterliakov
Copy link
Collaborator

Also, does this fix#19470 completely or partially? Please update the description to either remove "partially" or remove "fixes" magic word, so that half-resolved issue does not get autoclosed

randolf-scholz reacted with thumbs up emoji

randolf-scholzand others added4 commitsJuly 27, 2025 18:46
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@sterliakovsterliakov left a comment

Choose a reason for hiding this comment

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

Thanks! I like your docstring suggestion in the last comment, could you merge it?

@github-actions

This comment has been minimized.

@randolf-scholz
Copy link
ContributorAuthor

@sterliakov done.

Copy link
Member

@ilevkivskyiilevkivskyi left a comment

Choose a reason for hiding this comment

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

OK, looks like this is something worth trying

@github-actions
Copy link
Contributor

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

mitmproxy (https://github.com/mitmproxy/mitmproxy)+ mitmproxy/http.py:607: error: Unused "type: ignore" comment  [unused-ignore]

@ilevkivskyiilevkivskyi merged commit9c26271 intopython:masterOct 16, 2025
20 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ilevkivskyiilevkivskyiilevkivskyi approved these changes

+1 more reviewer

@sterliakovsterliakovsterliakov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

match-case class checking againstcollection.abc.Callable raises error [misc]

3 participants

@randolf-scholz@sterliakov@ilevkivskyi

[8]ページ先頭

©2009-2025 Movatter.jp