A minimal code snippet that reproduces the bug:
File test.py
from mytyping import Literal, overload
# from typing import Literal, overload
# from typing_extensions import Literal, overload
tag: Literal["a"] = "a"
@overload
def func(a: int):
...
@overload
def func(a: int, b: int):
...
def func(a: int, b: int = 0):
return a, b
File mytyping.py:
from typing import Literal, overload
__all__ = ["Literal", "overload"]
When using ruff check with from mytyping import Literal, overload enabled, I got:
$ ruff check test.py
test.py:5:15: F821 Undefined name `a`
test.py:14:5: F811 Redefinition of unused `func` from line 9
test.py:18:5: F811 Redefinition of unused `func` from line 14
Found 3 errors.
However, when uncomment either typing or typing_extensions, ruff check does not report above errors.
Ruff version:
$ ruff --version
ruff 0.0.286
A minimal code snippet that reproduces the bug:
File
test.pyFile
mytyping.py:When using
ruff checkwithfrom mytyping import Literal, overloadenabled, I got:However, when uncomment either
typingortyping_extensions,ruff checkdoes not report above errors.Ruff version: