Skip to content
Open
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
2 changes: 1 addition & 1 deletion nbdev/doclinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def patch_name(o):
if nm=='patch':
a = o.args.args[0].annotation
if isinstance(a, ast.BinOp): return _binop_leafs(a, o)
elif nm=='patch_to': a = d.args[0]
elif nm=='patch_to': a = d.args[0] if d.args else next(k.value for k in d.keywords if k.arg=='cls')
else: return o.name
return _sym_nm(a,o)

Expand Down
12 changes: 11 additions & 1 deletion nbs/api/05_doclinks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
" if nm=='patch': \n",
" a = o.args.args[0].annotation\n",
" if isinstance(a, ast.BinOp): return _binop_leafs(a, o)\n",
" elif nm=='patch_to': a = d.args[0]\n",
" elif nm=='patch_to': a = d.args[0] if d.args else next(k.value for k in d.keywords if k.arg=='cls')\n",
" else: return o.name\n",
" return _sym_nm(a,o)"
]
Expand Down Expand Up @@ -128,6 +128,16 @@
"test_eq('_T._g', _test_patch(s))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = \"@patch_to(cls=_T)\\ndef _h(self): ...\"\n",
"test_eq('_T._h', _test_patch(s))"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down