Type narrowing on object attribute with match statement doesn't apply #14911
Labels
feature
topic-match-statement
Python 3.10's match statement
topic-type-narrowing
Conditional type narrowing / binder
The bug
It seems that doing a "type checking" with the object UI in pattern matching seems to not work properly.
Attribute match is not considered.
Code
Expected behavior
By doing a match with
Test(a = int())
, python will checktest
is of typeTest
ANDtest.a
is of typeint
.But mypy "only assert" that
test
if of typeTest
. It keep the typeint | str
fortest.a
.Reproduce :
On mypy-playground :
https://mypy-play.net/?mypy=latest&python=3.11&gist=6f05124abd1ef68032d59651a7d5c6c3
The text was updated successfully, but these errors were encountered: