spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

"Online help" fails with AssertionError #15396

Open briantoby opened 3 years ago

briantoby commented 3 years ago

Problem Description

Display of docs of my Python modules in "Online help" sometimes fails

What steps reproduce the problem?

Clicking on the several of my Python modules in "Online help" reproducibly gives me a display with only the following three lines:

Error 
<module name>.html
AssertionError

What is the expected output? What do you see instead?

It does work for most of my modules. I originally found that the problem was that I did not have some of the packages I needed to import the modules in question in the Python that would not display, but I have since loaded and confirmed that I can view the documentation in pydoc in the same Python image I use to run spyder.

I am happy to debug, but need some suggestions on how.

Paste Traceback/Error Below (if applicable)

No messages in internal console

Versions

Note that this bug also shows up in other, older versions of Spyder

Dependencies


# Mandatory:
applaunchservices >=0.1.7     :  0.2.1 (OK)
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  1.6.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.19.0 (OK)
jedi =0.17.2                  :  0.17.2 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  21.7.0 (OK)
nbconvert >=4.0               :  6.0.7 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
parso =0.7.0                  :  0.7.0 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.7.2 (OK)
pygments >=2.0                :  2.7.3 (OK)
pylint >=1.0                  :  2.6.0 (OK)
pyls >=0.36.2;<1.0.0          :  v5.0.1+11.gb8e46d6a8 (NOK)
pyls_black >=0.4.6            :  0.4.6 (OK)
pyls_spyder >=0.3.2           :  0.3.2 (OK)
qdarkstyle =3.0.2             :  3.0.dev (NOK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.2 (OK)
qtconsole >=5.0.3             :  5.0.3 (OK)
qtpy >=1.5.0                  :  1.9.0 (OK)
rtree >=0.8.3                 :  0.9.4 (OK)
setuptools >=39.0.0           :  51.0.0.post20201207 (OK)
sphinx >=0.6.6                :  3.4.1 (OK)
spyder_kernels >=2.0.1;<2.1.0 :  2.1.0.dev0 (OK)
textdistance >=4.2.0          :  4.2.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0      :  0.10.4 (OK)
zmq >=17                      :  20.0.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=2.0.0            :  3.3.2 (OK)
numpy >=1.7                   :  1.19.2 (OK)
pandas >=1.1.1                :  None (NOK)
scipy >=0.17.0                :  1.5.2 (OK)
sympy >=0.7.3                 :  None (NOK)
juanis2112 commented 3 years ago

Hi @briantoby. I can successfully reproduce this bug. Some of my modules don't load as well. Maybe @dalthviz can give us an idea on why this could be happening or where to start debugging?

briantoby commented 3 years ago

I have gotten a bit farther on this and see that the assert is in pydoc_patch.CustomHTMLDoc.docclass. I have a hunch that the difference between modules that are displayed and the ones that give the assert error is related to if the module defines classes.

FWIW, removing the assert does allows me to see docs for those classes (though they are huge when inheriting from big classes). Will spend some more time on this.

ccordoba12 commented 3 years ago

Thanks for your help @briantoby!

briantoby commented 3 years ago

Ok a bit farther:

If I create a simple module, with functions and variables, pydoc_patch seems to work fine. As soon as I define a class -- no matter how simple -- the assert causes a problem. I really don't understand exactly what that while loop is supposed to be doing, but it seems that it is pulling info out of attrs, so I do not understand why if it is empty that should be a problem.

The above is wrong -- see later comment

A second issue is that if my class subclasses from something large (as an example, I use wx.Dialog often), then the docs get huge as all of the parent's definitions get included due to the attrs = inherited line. I would vote to remove that, so perhaps this should be an option for the plug-in.

ccordoba12 commented 3 years ago

This is great @briantoby! Would you mind creating a pull request with your changes?

For that, please follow our Contributing guide and make it against our 5.x branch (not 4.x):

https://github.com/spyder-ide/spyder/blob/master/CONTRIBUTING.md

briantoby commented 3 years ago

@ccordoba12 I am still coming up to speed on git. Also, I would like to see if I can figure out how to add an option for a plugin, but I will create a pull request with either some brain-dead changes (lines commented) or perhaps something a bit better.

ccordoba12 commented 3 years ago

No problem, any help is really appreciated.

briantoby commented 3 years ago

This is wrong:

If I create a simple module, with functions and variables, pydoc_patch seems to work fine. As soon as I define a class -- no matter how simple -- the assert causes a problem. I really don't understand exactly what that while loop is supposed to be doing, but it seems that it is pulling info out of attrs, so I do not understand why if it is empty that should be a problem.

Simple classes work fine, but in when I subclass, at least from wx, this error occurs. What is happening is that as each stanza of spill_____() works on the attrs, it pulls info out and at the assert point, if anything is left it is not included in the documentation. When I sublass wx.Dialog, there are still readonly items still left. Perhaps a warning should be included, but there is no reason to abort display IMHO.

briantoby commented 3 years ago

I have created a PR & updated it. I hope I have done this correctly. I am finding PRs in github rather bewildering.