amogorkon / justuse

Just use() code from anywhere - a functional import alternative with advanced features like inline version checks, autoreload, module globals injection before import and more.
MIT License
49 stars 8 forks source link

relative path doesn #480

Open amogorkon opened 2 years ago

amogorkon commented 2 years ago

in jupyter notebook 3.8

pipes = use(use.Path("../code/pipes.py")).pipes

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/tmp/ipykernel_3221/3387234922.py in <module>
----> 1 pipes = use(use.Path("../code/pipes.py")).pipes

~/anaconda3/lib/python3.8/site-packages/use/main.py in __call__(self, *args, **kwargs)
    133     def __call__(self, *args, **kwargs):
    134         with self.__condition:
--> 135             return self.__implementation(*args, **kwargs)
    136 
    137     # to allow `numpy @ use` for a quick check

~/anaconda3/lib/python3.8/site-packages/use/tools.py in wrapper(*args, **kwargs)
     44                 raise NirvanaWarning("No use trying to use Nothing.")
     45             args = args + (None,)
---> 46         return dispatcher.dispatch(args[1].__class__)(*args, **kwargs)
     47 
     48     wrapper.register = dispatcher.register

~/anaconda3/lib/python3.8/site-packages/use/main.py in _use_path(self, path, initial_globals, as_import, default, modes)
    487             exc = traceback.format_exc()
    488 
--> 489         with open(path, "rb") as rfile:
    490             code = rfile.read()
    491         try:

FileNotFoundError: [Errno 2] No such file or directory: '../code/pipes.py'