Allow typing.overload and typing_extensions.overload, fixes #1840, fixes #2117

This commit is contained in:
Dave Halter committed 2026-10-12 23:03:31 +02:00
1 parent 8a56168d9a
commit 91206f4c65
2 files changed
+29

No files matched your search

+4
View File
@@ -435,6 +435,10 @@ def _find_overload_functions(context, tree_node):
if dotted_name.type == 'name' and dotted_name.value == 'overload':
# TODO check with values if it's the right overload
return True
if dotted_name.type == 'atom_expr':
trailer = dotted_name.children[-1]
if trailer.children[0] == "." and trailer.children[1].value == "overload":
return True
return False
if tree_node.type == 'lambdef':
+25
View File
@@ -86,3 +86,28 @@ def broken_f1(value: Tuple[T]) -> Tuple[T]: ...
tup: Tuple[float]
#? float()
broken_f1(broken_f1(tup))[0]
# -------------------------
# Typing Extensions
# -------------------------
import typing_extensions
import typing
@typing_extensions.overload
def extensions(x: int) -> int: ...
@typing_extensions.overload
def extensions(x: str) -> str: ...
#? int()
extensions(1)
#? str()
extensions("")
@typing.overload
def typing_direct(x: int) -> int: ...
@typing.overload
def typing_direct(x: str) -> str: ...
#? int()
typing_direct(1)
#? str()
typing_direct("")