Inconsistent narrowing of Union and TypeVar with constraints and neglect of @final #10898
Labels
bug
mypy got something wrong
topic-final
PEP 591
topic-type-narrowing
Conditional type narrowing / binder
I had a short discussion about this with @JelleZijlstra on Gitter.
When narrowing the constrained type variable, Mypy seems to ignore the final decorator. When removing the final decorator, Mypy's output changes neither for the non-generic function f nor the generic function g. Shouldn't Mypy consistently report an error or not in both cases (regardless of marking the classes as final or not)? If I understand correctly, Mypy allows changing the signature of
__init__
when subclassing. So the reports are correct for f when using final and correct for g when not using final, aren't they?The text was updated successfully, but these errors were encountered: