You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[match-case] fix matching against typing.Callable and Protocol types. (#19471)
- Fixes#14014
- Partially addresses #19470
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.
---------
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
0 commit comments