Describe the bug
bytes | str incorrectly interpreted as bytes | bytearray | memoryview[_I@memoryview] | str
Code or Screenshots
This should type check
def fn(arg: bytes | str) -> str:
if isinstance(arg, bytes):
return arg.decode()
return arg
But it produces error:
/home/pavelaslanov/bytes-or-str-error.py
/home/pavelaslanov/bytes-or-str-error.py:4:12 - error: Expression of type "bytearray | memoryview[_I@memoryview] | str" is incompatible with return type "str"
Type "bytearray | memoryview[_I@memoryview] | str" is incompatible with type "str"
"bytearray" is incompatible with "str" (reportReturnType)
1 error, 0 warnings, 0 informations
VS Code extension or command-line
pyright 1.1.377