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
In the final two lines a class is assigned to a instance. MyPy thus reports
/tmp/protocol-test.py:19: error: Incompatible types in assignment (expression has type "Type[C]", variable has type "ProtoA")
/tmp/protocol-test.py:20: error: Incompatible types in assignment (expression has type "Type[C]", variable has type "ProtoB")
Found 2 errors in 1 file (checked 1 source file)
If I fix that (i.e. adding the missing '()'), than it seems as if the assignment to b should cause a type error, not the assignment to a. Mypy`s report is consistent to my presumption.
I hope it is ok to ask this, since I am here anyways: What is the difference between ... and pass? RTFM with link would be fine.
This is just a mypy bug (or rather a missing feature), it doesn't support class objects and modules as implementations of protocols, see python/mypy#4536
I am sorry to insist, but it still holds that the signatures for ProtoA and C match while these for ProtoB and C are in conflict. Thus, at least the comments must be swapped.
Activity
ilevkivskyi commentedon Nov 11, 2019
This is just a mypy bug (or rather a missing feature), it doesn't support class objects and modules as implementations of protocols, see python/mypy#4536
MaxG87 commentedon Nov 11, 2019
I am sorry to insist, but it still holds that the signatures for ProtoA and C match while these for ProtoB and C are in conflict. Thus, at least the comments must be swapped.
ilevkivskyi commentedon Nov 11, 2019
You can just try examples in REPL:
You can also read some tutorials about how bound and unbound methods work in Python.