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
{{ message }}
Repository navigation
Incorrect type narrowing for select class hierarchies #16379
I've found that in an exhaustive isinstance if block, mypy still leaves a more general type resolution than it should. In the snippet of code, mypy should be able to understand that there is no attr-defined error.
This is because mypy uses a join operator rather than unions when combining types from different code paths. join(B, D, E, F) is A. If it used unions instead, the resulting type of obj would be B | D | E | F, and no type error would result.
Activity
erictraut commentedon Oct 31, 2023
This is because mypy uses a join operator rather than unions when combining types from different code paths.
join(B, D, E, F)isA. If it used unions instead, the resulting type ofobjwould beB | D | E | F, and no type error would result.hauntsaninja commentedon Dec 30, 2025
Fixed in #18538