Skip to content

Conversation

@randolf-scholz
Copy link
Contributor

@randolf-scholz randolf-scholz commented Jul 17, 2025

Added extra logic in checker.py:conditional_types function to deal with structural types such as typing.Callable or protocols.

new tests

  • testMatchClassPatternCallable: tests case Callable() as fn usage
  • testMatchClassPatternProtocol: tests case Proto() usage, where Proto is a Protocol
  • testMatchClassPatternCallbackProtocol: tests case Proto() usage, where Proto is a Callback-Protocol
  • testGenericAliasIsinstanceUnreachable: derived from a mypy-primer failure in mesonbuild. Tests that isinstance(x, Proto) can produce unreachable error.
  • testGenericAliasRedundantExprCompoundIfExpr: derived from a CI failure of python 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-scholz randolf-scholz marked this pull request as draft July 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-scholz randolf-scholz marked this pull request as ready for review July 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

@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

@sterliakov sterliakov 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
Contributor Author

@sterliakov done.

Copy link
Member

@ilevkivskyi ilevkivskyi 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 from mypy_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]

@ilevkivskyi ilevkivskyi merged commit 9c26271 into python:master Oct 16, 2025
20 checks passed
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.

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

3 participants