Open
Description
openedon Feb 9, 2024
(this is probably known but wanted to document anyway)
VersionAdded (and potentially VersionChanged and Deprecated) are incorrectly parsed: the arguments of the directive (for example the version number for the change mentioned) are included in the directive title. When running papyri as an ipython extension this creates and error. For regular html rendering or textual/rich rendering this passes silently.
(papyri) ➜ papyri git:(main) ipython --ext papyri.ipython
Python 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.21.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import numpy as np
In [2]: np.einsum?
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~/projects/papyri/papyri/browser.py:229, in guess_load(rough, walk, gen_content, stack, frame)
228 try:
--> 229 load(candidates[0], walk, rough, gen_content, frame)
230 return True
File ~/projects/papyri/papyri/browser.py:217, in load(file_path, walk, qa, gen_content, frame)
216 assert hasattr(blob, "arbitrary")
--> 217 for i in gen_content(blob, frame):
218 walk.append(i)
File ~/projects/papyri/papyri/browser.py:577, in main.<locals>.gen_content(blob, frame)
576 doc.append(blank)
--> 577 doc.append(R.render(v))
578 if blob.see_also:
File ~/projects/papyri/papyri/browser.py:258, in Renderer.render(self, obj)
256 return urwid.Text(("unknown", "<" + obj.__class__.__name__ + ">"))
--> 258 return method(obj)
File ~/projects/papyri/papyri/browser.py:374, in Renderer.render_Section(self, section)
373 for c in section.children:
--> 374 acc.append(self.render(c))
375 # acc.append(Text("<Section Blank>"))
File ~/projects/papyri/papyri/browser.py:258, in Renderer.render(self, obj)
256 return urwid.Text(("unknown", "<" + obj.__class__.__name__ + ">"))
--> 258 return method(obj)
File ~/projects/papyri/papyri/browser.py:308, in Renderer.render_MAdmonition(self, adm)
307 if kind == "versionadded":
--> 308 title = "Added in Version " + adm.title
309 if kind == "deprecated":
AttributeError: 'MAdmonition' object has no attribute 'title'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_line_magic('pinfo', 'np.einsum')
File ~/micromamba/envs/papyri/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2456, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2454 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2455 with self.builtin_trap:
-> 2456 result = fn(*args, **kwargs)
2458 # The code below prevents the output from being displayed
2459 # when using magics with decorator @output_can_be_silenced
2460 # when the last Python token in the expression is a ';'.
2461 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~/projects/papyri/papyri/ipython.py:34, in Papyri.pinfo(self, parameter_s, namespaces)
32 if obj is not None:
33 qa = full_qual(obj)
---> 34 if _ := main(qa):
35 return
37 # print 'pinfo par: <%s>' % parameter_s # dbg
38 # detail_level: 0 -> obj? , 1 -> obj??
File ~/projects/papyri/papyri/browser.py:636, in main(qualname)
628 frame = urwid.Frame(urwid.AttrWrap(listbox, "body")) # , header=header)
629 frame.footer = urwid.AttrWrap(
630 urwid.Text(
631 "q: quit | ?: classic IPython help screen | Arrow/Click: focus links & navigate | enter: follow link"
632 ),
633 "header",
634 )
--> 636 found = guess_load(qualname, walk, gen_content, stack, frame)
637 if not found:
638 return False
File ~/projects/papyri/papyri/browser.py:232, in guess_load(rough, walk, gen_content, stack, frame)
230 return True
231 except Exception as e:
--> 232 raise ValueError(str(candidates)) from e
233 return False
ValueError: [PosixPath('/home/melissa/.papyri/ingest/numpy/1.26.3/module/numpy:einsum')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment