Skip to content

Commit 5d1702f

Browse files
committed
fixes #806
1 parent bac7156 commit 5d1702f

7 files changed

Lines changed: 120 additions & 355 deletions

File tree

fastcore/basics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,12 +1109,11 @@ def _inner(f):
11091109
for o in functools.WRAPPER_ASSIGNMENTS: setattr(nf, o, getattr(f,o))
11101110
nf.__name__ = _nm
11111111
nf.__qualname__ = f"{c_.__name__}.{_nm}"
1112+
if hasattr(c_, _nm) and not hasattr(c_, onm): setattr(c_, onm, getattr(c_, _nm))
11121113
if cls_method: attr = _clsmethod(nf)
11131114
elif set_prop: attr = getattr(c_, _nm).setter(nf)
11141115
elif as_prop: attr = property(nf)
1115-
else:
1116-
if hasattr(c_, _nm) and not hasattr(c_, onm): setattr(c_, onm, getattr(c_, _nm))
1117-
attr = nf
1116+
else: attr = nf
11181117
setattr(c_, _nm, attr)
11191118
return glb.get(_nm, builtins.__dict__.get(_nm, None))
11201119
return _inner

nbs/01_basics.ipynb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6519,12 +6519,11 @@
65196519
" for o in functools.WRAPPER_ASSIGNMENTS: setattr(nf, o, getattr(f,o))\n",
65206520
" nf.__name__ = _nm\n",
65216521
" nf.__qualname__ = f\"{c_.__name__}.{_nm}\"\n",
6522+
" if hasattr(c_, _nm) and not hasattr(c_, onm): setattr(c_, onm, getattr(c_, _nm))\n",
65226523
" if cls_method: attr = _clsmethod(nf)\n",
65236524
" elif set_prop: attr = getattr(c_, _nm).setter(nf)\n",
65246525
" elif as_prop: attr = property(nf)\n",
6525-
" else:\n",
6526-
" if hasattr(c_, _nm) and not hasattr(c_, onm): setattr(c_, onm, getattr(c_, _nm))\n",
6527-
" attr = nf\n",
6526+
" else: attr = nf\n",
65286527
" setattr(c_, _nm, attr)\n",
65296528
" return glb.get(_nm, builtins.__dict__.get(_nm, None))\n",
65306529
" return _inner"
@@ -8316,10 +8315,7 @@
83168315
]
83178316
}
83188317
],
8319-
"metadata": {
8320-
"solveit_dialog_mode": "learning",
8321-
"solveit_ver": 2
8322-
},
8318+
"metadata": {},
83238319
"nbformat": 4,
83248320
"nbformat_minor": 5
83258321
}

0 commit comments

Comments
 (0)