From 708f744baa780687dceea8b32f8e334ff258f6af Mon Sep 17 00:00:00 2001 From: seem Date: Fri, 1 Jul 2022 19:38:51 +1000 Subject: [PATCH] include annotations and qualname in `copy_func` --- fastcore/basics.py | 2 ++ nbs/01_basics.ipynb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fastcore/basics.py b/fastcore/basics.py index c23e9d17..a5b46edf 100644 --- a/fastcore/basics.py +++ b/fastcore/basics.py @@ -888,6 +888,8 @@ def copy_func(f): fn = FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__, f.__closure__) fn.__kwdefaults__ = f.__kwdefaults__ fn.__dict__.update(f.__dict__) + fn.__annotations__.update(f.__annotations__) + fn.__qualname__ = f.__qualname__ return fn # Cell diff --git a/nbs/01_basics.ipynb b/nbs/01_basics.ipynb index cb3c66a0..21d6fb6c 100644 --- a/nbs/01_basics.ipynb +++ b/nbs/01_basics.ipynb @@ -4676,6 +4676,8 @@ " fn = FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__, f.__closure__)\n", " fn.__kwdefaults__ = f.__kwdefaults__\n", " fn.__dict__.update(f.__dict__)\n", + " fn.__annotations__.update(f.__annotations__)\n", + " fn.__qualname__ = f.__qualname__\n", " return fn" ] },