Skip to content

Commit ead6827

Browse files
authored
Merge pull request #433 from fastai/fix-import
fix bug with `[source]`
2 parents 4ec1171 + a30cc5d commit ead6827

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

fastcore/xtras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .imports import *
1919
from .foundation import *
2020
from .basics import *
21-
21+
from importlib import import_module
2222
from functools import wraps
2323
import string,time
2424
from contextlib import contextmanager,ExitStack
@@ -366,7 +366,7 @@ def get_source_link(func):
366366
mod = inspect.getmodule(func)
367367
module = mod.__name__.replace('.', '/') + '.py'
368368
try:
369-
nbdev_mod = importlib.import_module(mod.__package__.split('.')[0] + '._nbdev')
369+
nbdev_mod = import_module(mod.__package__.split('.')[0] + '._nbdev')
370370
return f"{nbdev_mod.git_url}{module}#L{line}"
371371
except: return f"{module}#L{line}"
372372

nbs/03_xtras.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"from fastcore.imports import *\n",
3030
"from fastcore.foundation import *\n",
3131
"from fastcore.basics import *\n",
32-
"\n",
32+
"from importlib import import_module\n",
3333
"from functools import wraps\n",
3434
"import string,time\n",
3535
"from contextlib import contextmanager,ExitStack\n",
@@ -1592,7 +1592,7 @@
15921592
" mod = inspect.getmodule(func)\n",
15931593
" module = mod.__name__.replace('.', '/') + '.py'\n",
15941594
" try:\n",
1595-
" nbdev_mod = importlib.import_module(mod.__package__.split('.')[0] + '._nbdev')\n",
1595+
" nbdev_mod = import_module(mod.__package__.split('.')[0] + '._nbdev')\n",
15961596
" return f\"{nbdev_mod.git_url}{module}#L{line}\"\n",
15971597
" except: return f\"{module}#L{line}\""
15981598
]
@@ -2387,6 +2387,18 @@
23872387
"display_name": "Python 3 (ipykernel)",
23882388
"language": "python",
23892389
"name": "python3"
2390+
},
2391+
"language_info": {
2392+
"codemirror_mode": {
2393+
"name": "ipython",
2394+
"version": 3
2395+
},
2396+
"file_extension": ".py",
2397+
"mimetype": "text/x-python",
2398+
"name": "python",
2399+
"nbconvert_exporter": "python",
2400+
"pygments_lexer": "ipython3",
2401+
"version": "3.9.7"
23902402
}
23912403
},
23922404
"nbformat": 4,

0 commit comments

Comments
 (0)