Skip to content

Commit c9932a2

Browse files
authored
Merge pull request #425 from seeM/extend-copy-func
include annotations and qualname in `copy_func`
2 parents 71ec9e9 + 708f744 commit c9932a2

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

fastcore/basics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ def copy_func(f):
888888
fn = FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__, f.__closure__)
889889
fn.__kwdefaults__ = f.__kwdefaults__
890890
fn.__dict__.update(f.__dict__)
891+
fn.__annotations__.update(f.__annotations__)
892+
fn.__qualname__ = f.__qualname__
891893
return fn
892894

893895
# Cell

nbs/01_basics.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,6 +4676,8 @@
46764676
" fn = FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__, f.__closure__)\n",
46774677
" fn.__kwdefaults__ = f.__kwdefaults__\n",
46784678
" fn.__dict__.update(f.__dict__)\n",
4679+
" fn.__annotations__.update(f.__annotations__)\n",
4680+
" fn.__qualname__ = f.__qualname__\n",
46794681
" return fn"
46804682
]
46814683
},

0 commit comments

Comments
 (0)