google / pytype

A static type analyzer for Python code

Home Page:https://google.github.io/pytype

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

Thanks! This looks like #365.