I am on Python 3.8 and use MyPy 0.740
I consider the following example from PEP 544:
fromtypingimportAny, ProtocolclassProtoA(Protocol):
defmeth(self, x: int) ->int: ...
classProtoB(Protocol):
defmeth(self, obj: Any, x: int) ->int: ...
classC:
defmeth(self, x: int) ->int: ...
a: ProtoA=C# Type check error, signatures don't match!b: ProtoB=C# OK
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.
I am on Python 3.8 and use MyPy 0.740
I consider the following example from PEP 544:
In the final two lines a class is assigned to a instance. MyPy thus reports
If I fix that (i.e. adding the missing '()'), than it seems as if the assignment to
bshould cause a type error, not the assignment toa. 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
...andpass? RTFM with link would be fine.