Skip to content

Commit 5172e76

Browse files
authored
Merge pull request #816 from AnswerDotAI/fix/815-import-no-init-bug
fix import-no-init
2 parents 5cdf180 + 541417e commit 5172e76

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

fastcore/xtras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def import_no_init(name):
435435
from importlib.machinery import PathFinder
436436
import importlib.util as iu
437437
parts = name.split('.')
438-
spec = PathFinder.find_spec(parts[0])
438+
spec = PathFinder.find_spec(parts[0]) or iu.find_spec(parts[0])
439439
path = Path(spec.origin)
440440
if len(parts)>1: path = path.parent.joinpath(*parts[1:]).with_suffix('.py')
441441
spec = iu.spec_from_file_location(name, path)

nbs/03_xtras.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@
14151415
" from importlib.machinery import PathFinder\n",
14161416
" import importlib.util as iu\n",
14171417
" parts = name.split('.')\n",
1418-
" spec = PathFinder.find_spec(parts[0])\n",
1418+
" spec = PathFinder.find_spec(parts[0]) or iu.find_spec(parts[0])\n",
14191419
" path = Path(spec.origin)\n",
14201420
" if len(parts)>1: path = path.parent.joinpath(*parts[1:]).with_suffix('.py')\n",
14211421
" spec = iu.spec_from_file_location(name, path)\n",

0 commit comments

Comments
 (0)