fastai / fastcore

Python supercharged for the fastai library
http://fastcore.fast.ai
Apache License 2.0
964 stars 276 forks source link

Documentation of necessary imports, odd exceptions #282

Closed johann-petrak closed 3 years ago

johann-petrak commented 3 years ago

Running python 3.8.5 on Linux, installed fastcore and ipython into a fresh conda environment.

In IPython I have copy-pasted the imports as shown in the documentation (Basic functionality):

from fastcore.test import *
from nbdev.showdoc import *
from fastcore.nb_imports import *

After this, trying the first method in that documentation (ifnone) is not found. basic_repr, is_array are not found either. So the import from fastcore.basics import * is missing in the documentation page.

Similar, the 3 imports shown on the documentation page are the same as for the basics page but the import from fastcore.foundation is not included. This is confusing at least to me.

Also, I get the following exception when I do imports or try to use an imported object, but at random times:

Traceback (most recent call last):
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 113, in get_completions
    yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 129, in _get_completions
    for c in completions:
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
    completions = list(completions)
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/core/completer.py", line 1818, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions
    matched_text, matches, matches_origin, jedi_matches = self._complete(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete
    completions = self._jedi_matches(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches
    interpreter = jedi.Interpreter(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/jedi/api/__init__.py", line 725, in __init__
    super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/johann/software/anaconda/envs/nbdev/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/traitlets/config/application.py", line 845, in launch_instance
    app.start()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 564, in mainloop
    self.interact()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 547, in interact
    code = self.prompt_for_code()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 473, in prompt_for_code
    text = self.pt_app.prompt(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1013, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 816, in run
    return loop.run_until_complete(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 783, in run_async
    return await _run_async2()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 771, in _run_async2
    await self.cancel_and_wait_for_background_tasks()
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 872, in cancel_and_wait_for_background_tasks
    await task
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/buffer.py", line 1854, in new_coroutine
    await coroutine(*a, **kw)
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/buffer.py", line 1683, in async_completer
    async for completion in self.completer.get_completions_async(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/completion/base.py", line 269, in get_completions_async
    async for completion in completer.get_completions_async(
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/prompt_toolkit/completion/base.py", line 196, in get_completions_async
    for item in self.get_completions(document, complete_event):
  File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 116, in get_completions
    exc_type, exc_value, exc_tb = sys.exc_info()
NameError: name 'sys' is not defined

If you suspect this is an IPython 7.19.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True
hamelsmu commented 3 years ago

Can you do me a favor and attempt to reproduce this in a Colab notebook? I'm having trouble reproducing this error. Thank you