Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…eckable test should be performed elsewhere.
…on and anonymous `Callable`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
39eedb4 to74db0aaCompare This comment has been minimized.
This comment has been minimized.
3418149 tod62d6d2Compare This comment has been minimized.
This comment has been minimized.
d62d6d2 to143f990Compare This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
sterliakov commentedJul 27, 2025
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 |
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
for more information, seehttps://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
sterliakov left a comment
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.
Thanks! I like your docstring suggestion in the last comment, could you merge it?
This comment has been minimized.
This comment has been minimized.
randolf-scholz commentedOct 11, 2025
@sterliakov done. |
ilevkivskyi left a comment
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.
OK, looks like this is something worth trying
Uh oh!
There was an error while loading.Please reload this page.
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] |
9c26271 intopython:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
collection.abc.Callableraises error [misc] #14014AnyCallableProtocol differs fromcallable()check #19470Added extra logic in
checker.py:conditional_typesfunction to deal with structural types such astyping.Callableor protocols.new tests
testMatchClassPatternCallable: testscase Callable() as fnusagetestMatchClassPatternProtocol: testscase Proto()usage, whereProtois a ProtocoltestMatchClassPatternCallbackProtocol: testscase Proto()usage, whereProtois a Callback-ProtocoltestGenericAliasIsinstanceUnreachable: 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 selfof an earlier version of this PR.modified tests
testOverloadOnProtocoladded annotations to overload implementation, which wasn't getting checked. Added missing return. Fixed return type in second branch.