Skip to content

Share mwe for the annotation error #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

OriolAbril
Copy link
Contributor

@OriolAbril OriolAbril commented Oct 19, 2021

Related to #44. I tracked the error down to the presence of np.random.<distribution> type function calls.

  • Tests written and passed
  • Documentation and changelog entry written, docs build passed
  • All tox checks passed

@felix-hilden
Copy link
Owner

felix-hilden commented Oct 19, 2021

Uhm, thanks for the example, but it appears to work 😅 maybe something is needed after the call?

@OriolAbril
Copy link
Contributor Author

OriolAbril commented Oct 19, 2021

Maybe it's some kind of version issue? I am using sphinx 4.2 and have tried both docutils 0.16 and 0.17.1 and it does not work for me locally. I remove the build directory and run make html to get

Running Sphinx v4.2.0
making output directory... done
loading intersphinx inventory from https://numpy.org/doc/stable/objects.inv...
loading intersphinx inventory from https://matplotlib.org/stable/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 7 source files that are out of date
updating environment: [new config] 7 added, 0 changed, 0 removed
reading sources... [100%] release_notes                                                                                                                                                
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/oriol/Public/sphinx-codeautolink/docs/src/404.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [ 14%] 404                                                                                                                                                           
Extension error (sphinx_codeautolink.extension):
Handler <bound method SphinxCodeAutoLink.generate_backref_tables of <sphinx_codeautolink.extension.SphinxCodeAutoLink object at 0x7fbc6b369850>> for event 'doctree-resolved' threw an exception (exception: 'builtin_function_or_method' object has no attribute '__annotations__')
make: *** [Makefile:19: html] Error 2

if I remove that line and change nothing it works, I add it again it breaks

@felix-hilden
Copy link
Owner

I'll have a look around the code later today to see the exact line and its surroundings. Maybe we can make an educated guess and at least catch the error gracefully if we can't find the source.

Could you paste your Python version and pip freeze in a clean environment here?

@OriolAbril
Copy link
Contributor Author

Here is the broken env:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
alabaster                 0.7.12                   pypi_0    pypi
anyio                     3.3.4                    pypi_0    pypi
argon2-cffi               21.1.0                   pypi_0    pypi
attrs                     20.3.0                   pypi_0    pypi
babel                     2.9.1                    pypi_0    pypi
backcall                  0.2.0                    pypi_0    pypi
backports-entry-points-selectable 1.1.0                    pypi_0    pypi
beautifulsoup4            4.10.0                   pypi_0    pypi
bleach                    4.1.0                    pypi_0    pypi
bokeh                     2.4.1                    pypi_0    pypi
build                     0.7.0                    pypi_0    pypi
ca-certificates           2021.10.8            ha878542_0    conda-forge
certifi                   2021.10.8                pypi_0    pypi
cffi                      1.15.0                   pypi_0    pypi
cftime                    1.5.1                    pypi_0    pypi
charset-normalizer        2.0.7                    pypi_0    pypi
colorama                  0.4.4                    pypi_0    pypi
coverage                  6.0.2                    pypi_0    pypi
cryptography              35.0.0                   pypi_0    pypi
cycler                    0.10.0                   pypi_0    pypi
debugpy                   1.5.1                    pypi_0    pypi
decorator                 5.1.0                    pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
distlib                   0.3.3                    pypi_0    pypi
doc8                      0.9.1                    pypi_0    pypi
docutils                  0.16                     pypi_0    pypi
entrypoints               0.3                      pypi_0    pypi
filelock                  3.3.1                    pypi_0    pypi
flake8                    4.0.1                    pypi_0    pypi
flake8-bugbear            21.9.2                   pypi_0    pypi
ghp-import                2.0.2                    pypi_0    pypi
gitdb                     4.0.7                    pypi_0    pypi
gitpython                 3.1.24                   pypi_0    pypi
greenlet                  1.1.2                    pypi_0    pypi
idna                      3.3                      pypi_0    pypi
imagesize                 1.2.0                    pypi_0    pypi
importlib-metadata        4.8.1                    pypi_0    pypi
iniconfig                 1.1.1                    pypi_0    pypi
ipykernel                 6.4.1                    pypi_0    pypi
ipython                   7.28.0                   pypi_0    pypi
ipython-genutils          0.2.0                    pypi_0    pypi
ipywidgets                7.6.5                    pypi_0    pypi
jedi                      0.18.0                   pypi_0    pypi
jeepney                   0.7.1                    pypi_0    pypi
jinja2                    3.0.2                    pypi_0    pypi
jsonschema                4.1.0                    pypi_0    pypi
jupyter-cache             0.4.3                    pypi_0    pypi
jupyter-client            7.0.6                    pypi_0    pypi
jupyter-core              4.8.1                    pypi_0    pypi
jupyter-server            1.11.1                   pypi_0    pypi
jupyter-server-mathjax    0.2.3                    pypi_0    pypi
jupyter-sphinx            0.3.2                    pypi_0    pypi
jupyterlab-widgets        1.0.2                    pypi_0    pypi
keyring                   23.2.1                   pypi_0    pypi
kiwisolver                1.3.2                    pypi_0    pypi
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libffi                    3.4.2                h9c3ff4c_4    conda-forge
libgcc-ng                 11.2.0              h1d223b6_11    conda-forge
libgomp                   11.2.0              h1d223b6_11    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_11    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
markdown-it-py            0.6.2                    pypi_0    pypi
markupsafe                2.0.1                    pypi_0    pypi
matplotlib                3.4.3                    pypi_0    pypi
matplotlib-inline         0.1.3                    pypi_0    pypi
mccabe                    0.6.1                    pypi_0    pypi
mdit-py-plugins           0.2.6                    pypi_0    pypi
mistune                   0.8.4                    pypi_0    pypi
myst-nb                   0.12.3                   pypi_0    pypi
myst-parser               0.13.7                   pypi_0    pypi
nbclient                  0.5.4                    pypi_0    pypi
nbconvert                 5.6.1                    pypi_0    pypi
nbdime                    3.1.0                    pypi_0    pypi
nbformat                  5.1.3                    pypi_0    pypi
ncurses                   6.2                  h58526e2_4    conda-forge
nest-asyncio              1.5.1                    pypi_0    pypi
netcdf4                   1.5.7                    pypi_0    pypi
notebook                  6.4.5                    pypi_0    pypi
numpy                     1.21.2                   pypi_0    pypi
numpydoc                  1.1.0                    pypi_0    pypi
openssl                   3.0.0                h7f98852_1    conda-forge
packaging                 21.0                     pypi_0    pypi
pandas                    1.3.4                    pypi_0    pypi
pandocfilters             1.5.0                    pypi_0    pypi
parso                     0.8.2                    pypi_0    pypi
pbr                       5.6.0                    pypi_0    pypi
pep517                    0.12.0                   pypi_0    pypi
pexpect                   4.8.0                    pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pillow                    8.4.0                    pypi_0    pypi
pip                       21.3               pyhd8ed1ab_0    conda-forge
pkginfo                   1.7.1                    pypi_0    pypi
platformdirs              2.4.0                    pypi_0    pypi
pluggy                    1.0.0                    pypi_0    pypi
prometheus-client         0.11.0                   pypi_0    pypi
prompt-toolkit            3.0.20                   pypi_0    pypi
ptyprocess                0.7.0                    pypi_0    pypi
py                        1.10.0                   pypi_0    pypi
pycodestyle               2.8.0                    pypi_0    pypi
pycparser                 2.20                     pypi_0    pypi
pydata-sphinx-theme       0.7.1                    pypi_0    pypi
pydocstyle                6.1.1                    pypi_0    pypi
pyflakes                  2.4.0                    pypi_0    pypi
pygments                  2.10.0                   pypi_0    pypi
pyparsing                 2.4.7                    pypi_0    pypi
pyrsistent                0.18.0                   pypi_0    pypi
pytest                    6.2.5                    pypi_0    pypi
python                    3.9.7           hf930737_3_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.3                   pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
pyzmq                     22.3.0                   pypi_0    pypi
readline                  8.1                  h46c0cb4_0    conda-forge
readme-renderer           30.0                     pypi_0    pypi
requests                  2.26.0                   pypi_0    pypi
requests-toolbelt         0.9.1                    pypi_0    pypi
requests-unixsocket       0.2.0                    pypi_0    pypi
restructuredtext-lint     1.3.2                    pypi_0    pypi
rfc3986                   1.5.0                    pypi_0    pypi
scipy                     1.7.1                    pypi_0    pypi
secretstorage             3.3.1                    pypi_0    pypi
send2trash                1.8.0                    pypi_0    pypi
setuptools                58.2.0           py39hf3d152e_0    conda-forge
six                       1.16.0                   pypi_0    pypi
smmap                     4.0.0                    pypi_0    pypi
sniffio                   1.2.0                    pypi_0    pypi
snowballstemmer           2.1.0                    pypi_0    pypi
soupsieve                 2.2.1                    pypi_0    pypi
sphinx                    3.5.4                    pypi_0    pypi
sphinx-codeautolink       0.4.0                    pypi_0    pypi
sphinx-copybutton         0.4.0                    pypi_0    pypi
sphinx-notfound-page      0.7.1                    pypi_0    pypi
sphinx-panels             0.6.0                    pypi_0    pypi
sphinx-rtd-theme          1.0.0                    pypi_0    pypi
sphinx-togglebutton       0.2.3                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.2                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.2                    pypi_0    pypi
sphinxcontrib-htmlhelp    2.0.0                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.3                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.5                    pypi_0    pypi
sqlalchemy                1.4.25                   pypi_0    pypi
sqlite                    3.36.0               h9cd32fc_2    conda-forge
stevedore                 3.5.0                    pypi_0    pypi
terminado                 0.12.1                   pypi_0    pypi
testpath                  0.5.0                    pypi_0    pypi
tk                        8.6.11               h27826a3_1    conda-forge
toml                      0.10.2                   pypi_0    pypi
tomli                     1.2.1                    pypi_0    pypi
tornado                   6.1                      pypi_0    pypi
tox                       3.24.4                   pypi_0    pypi
tqdm                      4.62.3                   pypi_0    pypi
traitlets                 5.1.0                    pypi_0    pypi
twine                     3.4.2                    pypi_0    pypi
typing-extensions         3.10.0.2                 pypi_0    pypi
tzdata                    2021d                he74cb21_0    conda-forge
urllib3                   1.26.7                   pypi_0    pypi
virtualenv                20.8.1                   pypi_0    pypi
wcwidth                   0.2.5                    pypi_0    pypi
webencodings              0.5.1                    pypi_0    pypi
websocket-client          1.2.1                    pypi_0    pypi
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
widgetsnbextension        3.5.1                    pypi_0    pypi
xarray                    0.19.0                   pypi_0    pypi
xz                        5.2.5                h516909a_1    conda-forge
zipp                      3.6.0                    pypi_0    pypi
zlib                      1.2.11            h36c2ea0_1013    conda-forge

It is a bit bloated because these are the requirements for both sphinx-codeautolink[dev] and the doc only dependencies for arviz (what we install for our rtd build -> matplotlib, bokeh, myst... to get extra directives and arviz dependencies to get arviz to autoexecute the code examples via those third party directives).

I have created a minimal env with sphinx-codeautolink[dev] only I too was able to build the docs including the np.random.normal line. I am trying to find version incompatibilities as changing the env was all it took to break things but so far I can't pinpoint the issue

@felix-hilden
Copy link
Owner

Oh I see, thanks for digging in! At least it's good to know that the simple case works for you too.

@OriolAbril
Copy link
Contributor Author

Issue seems to be with bokeh somehow. Here is what I did:

Create fresh environment with python 3.9. Install codeautolink[dev]. Run make html in docs folder and sucessfully generate the docs from this branch. Install bokeh and remove the build folder. Run make html and reproduce the annotations error

@felix-hilden
Copy link
Owner

So a seemingly unrelated package is changing the way numpy behaves and breaking this extension. Wow 😅 okay, I'll investigate later myself. Thanks a bunch for the debugging!

@felix-hilden
Copy link
Owner

I managed to reproduce it without Bokeh! Though the underlying cause is still a bit unclear, numpy.random.normal is a built-in method. numpy.random.mtrand.RandomState.normal which it's an alias of isn't. In any case, it doesn't have annotations, the error in the latter case being: "method_descriptor object has no attribute annotations". I think I'll stop the debugging here and just safeguard the missing annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants