Running into a couple of issues with memoryview annotations.
Consider the following python3 program:
def fn(packet: memoryview) -> bytes:
if chr(packet[0]) == "\xff":
return packet.tobytes()
else:
return b"fail"
print(fn(memoryview(b"\xffabc")))
print(fn(memoryview(b"\xfeabc")))
Which when run has the following output:
Presently mypy gives the following errors for this program:
$ mypy tmp/test.py
tmp/test.py: note: In function "fn":
tmp/test.py:2: error: Value of type "memoryview" is not indexable
tmp/test.py:3: error: "memoryview" has no attribute "tobytes"
tmp/test.py: note: At top level:
tmp/test.py:7: error: Argument 1 to "memoryview" has incompatible type "bytes"; expected "bytearray"
tmp/test.py:8: error: Argument 1 to "memoryview" has incompatible type "bytes"; expected "bytearray"
Each of the errors claimed here is incorrect.
Running into a couple of issues with memoryview annotations.
Consider the following python3 program:
Which when run has the following output:
Presently mypy gives the following errors for this program:
Each of the errors claimed here is incorrect.