pytype doesn't raise any errors in operations between Union of types (int | str) and a single int literal
p-malecki opened this issue · comments
Paweł Małecki commented
I found out that pytype doesn't raise any errors in operations between a Union of types (int | str) and a single int literal.
I suppose it's a known bug, but I haven't found it in open issues.
Example Code
from typing import Union
a: Union[int, str] = "abc"
b = a + 123
Expected Behavior
unsupported operand type(s)
Actual Behavior
Success: no errors found
In runtime, the example results in a TypeError.
System info
$ python --version
Python 3.11.6
$ pytype --version
2024.01.05
Rebecca Chen commented
Thanks! This looks like #365.