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
main.py:20: error: Argument 1 to "permissions_for" of "A" has incompatible type "Union[UserTypeA, UserTypeB]"; expected "UserTypeA"
main.py:20: error: Argument 1 to "permissions_for" of "B" has incompatible type "Union[UserTypeA, UserTypeB]"; expected "UserTypeB"
Expected behaviour:
No error as x.me matches the type expected by x.permissions_for - if instance of A is passed x.me will have type UserTypeA and x.permissions_for will expect UserTypeA and same for instance of B.
Also, if func looks like this, the errors are gone so if mypy could infer this without isinstance it would be great:
This is probably too difficult for mypy to understand, but leaving open as a low-priority issue in case somebody comes up with a simple way to support this.
Honestly didn't know how to name this issue...
Issue type: Bug
Problematic code:
Error message:
Expected behaviour:
No error as
x.me
matches the type expected byx.permissions_for
- if instance ofA
is passedx.me
will have typeUserTypeA
andx.permissions_for
will expectUserTypeA
and same for instance ofB
.Also, if
func
looks like this, the errors are gone so if mypy could infer this withoutisinstance
it would be great:Python version:: 3.8.1
Mypy version: 0.761, occurs on master as well
Mypy flags: No flags
The text was updated successfully, but these errors were encountered: