Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6646,6 +6646,26 @@ def test_overload_registry_repeated(self):

self.assertEqual(list(get_overloads(impl)), overloads)

def test_overload_wraps(self):
@overload
def norwegian_blue(x: "int"):
"""pining for the fjords"""

self.assertEqual(norwegian_blue.__doc__, "pining for the fjords")
self.assertEqual(norwegian_blue.__name__, "norwegian_blue")
self.assertEqual(norwegian_blue.__annotations__, {"x": "int"})

# But also make sure this isn't the same function each time
setattr(norwegian_blue, "sentinel", object())

@overload
def ex_parrot():
"""ceased to be"""

self.assertFalse(hasattr(ex_parrot, "sentinel"))
self.assertEqual(ex_parrot.__doc__, "ceased to be")
self.assertEqual(norwegian_blue.__doc__, "pining for the fjords")


from test.typinganndata import (
ann_module, ann_module2, ann_module3, ann_module5, ann_module6,
Expand Down
2 changes: 1 addition & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,7 @@ def utf8(value):
except AttributeError:
# Not a normal function; ignore.
pass
return _overload_dummy
return functools.wraps(func)(lambda *args, **kwds: _overload_dummy(*args, **kwds))


def get_overloads(func):
Expand Down
Loading