-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Sphinx 7.2 breaks Matplotlib's directive with Jax's arrays #11652
Comments
Hi Jérome (@jeertmans), Please would you be able to paste the full log mentioned in the failure message, and ideally also the untruncated Additionally, please may you try to reduce the set of extensions as much as possible -- certainly removing Thanks, |
Ok so I managed to have a MWE. The error is not the same, but it also occurs when upgrading to Sphinx 7.2.
[tool.poetry]
name = "sphinx-11652-mwe"
version = "0.1.0"
description = ""
authors = ["Jérome Eertmans <jeertmans@icloud.com>"]
readme = "README.md"
packages = [{include = "sphinx_11652_mwe"}]
[tool.poetry.dependencies]
python = "^3.10"
sphinx = "<7.2" # Works
# sphinx = ">=7.2" # Fails
jax = {extras = ["cpu"], version = "^0.4.14"}
matplotlib = "^3.7.2"
chex = "^0.1.82"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
from __future__ import annotations
import jax.numpy as jnp
from chex import dataclass
from jax import Array
@dataclass
class Foo:
"""
.. plot::
import matplotlib.pyplot as plt
from sphinx_11652_mwe import Foo
n = 5
f = Foo.from_size(n)
plt.plot(f.x[n:], f.x[:n])
plt.show()
"""
x: Array
@classmethod
def from_size(cls, n: int) -> Foo:
return cls(x=jnp.arange(2 * n))
project = 'test'
copyright = '2023, NA'
author = 'NA'
extensions = [
'sphinx.ext.autodoc',
'matplotlib.sphinxext.plot_directive'
]
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']
Welcome to test's documentation!
================================
.. automodule:: sphinx_11652_mwe
:members: Output from failing build: Full tracebackWARNING: autodoc: failed to import module 'sphinx_11652_mwe'; the following exception was raised:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
return importlib.import_module(modname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 3, in <module>
import jax.numpy as jnp
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/__init__.py", line 169, in <module>
from jax import scipy as scipy
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/__init__.py", line 24, in <module>
from jax.scipy import signal as signal
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/signal.py", line 18, in <module>
from jax._src.scipy.signal import (
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/scipy/signal.py", line 23, in <module>
import scipy.signal as osp_signal
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/__init__.py", line 323, in <module>
from ._filter_design import *
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/_filter_design.py", line 16, in <module>
from scipy import special, optimize, fft as sp_fft
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/__init__.py", line 211, in __getattr__
return _importlib.import_module(f'scipy.{name}')
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/__init__.py", line 424, in <module>
from ._direct_py import direct
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/_direct_py.py", line 13, in <module>
from _typeshed import NoneType
ModuleNotFoundError: No module named '_typeshed'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 88, in import_object
module = import_module(modname, warningiserror=warningiserror)
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 68, in import_module
raise ImportError(exc, traceback.format_exc()) from exc
ImportError: (ModuleNotFoundError("No module named '_typeshed'"), 'Traceback (most recent call last):\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module\n return importlib.import_module(modname)\n File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1027, in _find_and_load\n File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 688, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 883, in exec_module\n File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\n File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 3, in <module>\n import jax.numpy as jnp\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/__init__.py", line 169, in <module>\n from jax import scipy as scipy\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/__init__.py", line 24, in <module>\n from jax.scipy import signal as signal\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/signal.py", line 18, in <module>\n from jax._src.scipy.signal import (\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/scipy/signal.py", line 23, in <module>\n import scipy.signal as osp_signal\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/__init__.py", line 323, in <module>\n from ._filter_design import *\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/_filter_design.py", line 16, in <module>\n from scipy import special, optimize, fft as sp_fft\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/__init__.py", line 211, in __getattr__\n return _importlib.import_module(f\'scipy.{name}\')\n File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/__init__.py", line 424, in <module>\n from ._direct_py import direct\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/_direct_py.py", line 13, in <module>\n from _typeshed import NoneType\nModuleNotFoundError: No module named \'_typeshed\'\n')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
return importlib.import_module(modname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 4, in <module>�[91mWARNING: autodoc: failed to import module 'sphinx_11652_mwe'; the following exception was raised:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
return importlib.import_module(modname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 3, in <module>
import jax.numpy as jnp
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/__init__.py", line 169, in <module>
from jax import scipy as scipy
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/__init__.py", line 24, in <module>
from jax.scipy import signal as signal
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/signal.py", line 18, in <module>
from jax._src.scipy.signal import (
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/scipy/signal.py", line 23, in <module>
import scipy.signal as osp_signal
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/__init__.py", line 323, in <module>
from ._filter_design import *
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/_filter_design.py", line 16, in <module>
from scipy import special, optimize, fft as sp_fft
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/__init__.py", line 211, in __getattr__
return _importlib.import_module(f'scipy.{name}')
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/__init__.py", line 424, in <module>
from ._direct_py import direct
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/_direct_py.py", line 13, in <module>
from _typeshed import NoneType
ModuleNotFoundError: No module named '_typeshed'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 88, in import_object
module = import_module(modname, warningiserror=warningiserror)
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 68, in import_module
raise ImportError(exc, traceback.format_exc()) from exc
ImportError: (ModuleNotFoundError("No module named '_typeshed'"), 'Traceback (most recent call last):\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module\n return importlib.import_module(modname)\n File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1027, in _find_and_load\n File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 688, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 883, in exec_module\n File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\n File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 3, in <module>\n import jax.numpy as jnp\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/__init__.py", line 169, in <module>\n from jax import scipy as scipy\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/__init__.py", line 24, in <module>\n from jax.scipy import signal as signal\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/scipy/signal.py", line 18, in <module>\n from jax._src.scipy.signal import (\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/scipy/signal.py", line 23, in <module>\n import scipy.signal as osp_signal\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/__init__.py", line 323, in <module>\n from ._filter_design import *\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/signal/_filter_design.py", line 16, in <module>\n from scipy import special, optimize, fft as sp_fft\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/__init__.py", line 211, in __getattr__\n return _importlib.import_module(f\'scipy.{name}\')\n File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/__init__.py", line 424, in <module>\n from ._direct_py import direct\n File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/scipy/optimize/_direct_py.py", line 13, in <module>\n from _typeshed import NoneType\nModuleNotFoundError: No module named \'_typeshed\'\n')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
return importlib.import_module(modname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/export/home/eertmans/Desktop/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py", line 4, in <module>
from chex import dataclass
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/__init__.py", line 17, in <module>
from chex._src.asserts import assert_axis_dimension
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/asserts.py", line 27, in <module>
from chex._src import asserts_internal as _ai
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/asserts_internal.py", line 34, in <module>
from chex._src import pytypes
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/pytypes.py", line 53, in <module>
Shape = jax.core.Shape
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/deprecations.py", line 53, in getattr
raise AttributeError(f"module {module!r} has no attribute {name!r}")
AttributeError: module 'jax' has no attribute 'core'
�[39;49;00m
from chex import dataclass
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/__init__.py", line 17, in <module>
from chex._src.asserts import assert_axis_dimension
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/asserts.py", line 27, in <module>
from chex._src import asserts_internal as _ai
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/asserts_internal.py", line 34, in <module>
from chex._src import pytypes
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/chex/_src/pytypes.py", line 53, in <module>
Shape = jax.core.Shape
File "/home/eertmans/.cache/pypoetry/virtualenvs/sphinx-11652-mwe-IiPyajJx-py3.10/lib/python3.10/site-packages/jax/_src/deprecations.py", line 53, in getattr
raise AttributeError(f"module {module!r} has no attribute {name!r}")
AttributeError: module 'jax' has no attribute 'core' I have attached the project files if you prefer. |
Ah it's maybe because of some |
That's what I thought, too, but what change in 7.2 could have cause that? |
@jeertmans -- I'm not able to reproduce the error you're seeing. I get:
with: Heading
=======
.. automodule:: sphinx_11652_mwe
:members: import os, sys
sys.path.insert(0, os.path.abspath('.'))
extensions = [
'sphinx.ext.autodoc',
'matplotlib.sphinxext.plot_directive'
]
exclude_patterns = [
'.venv',
]
html_theme = 'alabaster' from __future__ import annotations
import jax.numpy as jnp
from chex import dataclass
from jax import Array
@dataclass
class Foo:
"""
.. plot::
import matplotlib.pyplot as plt
from sphinx_11652_mwe import Foo
f = Foo.from_size(5)
plt.plot(f.x[5:], f.x[:5])
plt.show()
"""
x: Array
@classmethod
def from_size(cls, n: int) -> Foo:
return cls(x=jnp.arange(2 * n)) Are you able to check without Poetry please? I ran: A |
I get the exact same error message as you when I do not use poetry. But what is also weird is that when I Anyway, having |
Not entirely sure, but I'm wondering how matplotlib actually executes the code. Maybe it is an issue with what the local namespace consists of? Also, could you like print the type of f.x and check what happens? (I never used the plot directive) and check the output of jnp.arange(...) in the classmethod itself. Finally, is the chex.dataclass possibly responsible for this? can you use a real dataclass instead and real functions to create your dataclass (still with this Array annotation)? |
I guess so.. Printing /home/jeertmans/Downloads/sphinx-11652-mwe/sphinx_11652_mwe/__init__.py:docstring of sphinx_11652_mwe.Foo:1: WARNING: Exception occurred in plotting index-1
from /home/jeertmans/Downloads/sphinx-11652-mwe/source/index.rst:
Traceback (most recent call last):
File "/home/jeertmans/Downloads/sphinx-11652-mwe/venv/lib/python3.10/site-packages/matplotlib/sphinxext/plot_directive.py", line 481, in _run_code
exec(code, ns)
File "<string>", line 8, in <module>
ValueError: <jaxlib.xla_extension.ArrayImpl object at 0x562f77bb2070> Changing |
What about jnp.arange? By the way, maybe it's an issue on jax then? Or matplotlib and its compatibility with jax (can you bisect the (Sphinx) commit responsibile for the issue?) |
This faulty (but quite lengthy) commit is: ad61e41. |
More precisely, the error can be fixed with this checkout: |
It's quite unexpected, to me, that the autodoc importer would set |
It's intentional, as there are often e.g. typing or collections.abc imports in the TYPE_CHECKING block, which are needed for documentation. However, it should be that failure to import with TYPE_CHECKING=True falls back to TYPE_CHECKING=False. |
Running autodoc on this works:
But fails with Jax:
I suspect therefore the problem is with Jax -- they'll also break with runtime type checkers (e.g. pyanalyze), I believe. A |
But here we are also talking about import within docstrings. I totally get that importing with type checking enabled is importing when running auto doc on a module for example. But why importing the content of the docstring also with type checking set to True? |
@AA-Turner by looking at the different arguments in different issues, I think we should not set While it does indeed reduce the capability of Sphinx to discover new modules, I think it's more likely that we would hit more and more issues if we were to blindly set IMO, we should make the feature experimental and disabled by default while highlighting its limitations. Alternatively, we could suggest "default" type aliases instead or an enhanced mechanism for type aliases. For my personal projects, I either use This would only work for projects that only use "standard" types. For others, I think they should manually specify the type aliases to use. I n addition, I think we could enhance the current Ideally, we should rather develop our static analysis tool rather than relying on dynamic analysis since we could on techniques from other tools and avoid runtime surprises. |
@jeertmans With #11679 being merged, I think you shouldn't have issues, so we may close the issue unless the issue persists. |
Is it already part of any release @picnixz? |
7.2.6 |
Ok, I can confirm that it works under 7.2.6, thanks for the patch! |
Describe the bug
Hello,
When using the usual
make html
, I faced the following issue (minimized):As you can see, they say that
ArrayImpl
is not indexable. Butself.point
(and others) should not be aArrayImpl
, but rather some concrete array value. When runningpytest
and other commands, I get the expected output. When building withSphinx<7.2
, it works as expected. I don't know what triggers thisArrayImpl
type to be used, and this may be a side effect of using Jax.This issue is faced when combining
Sphinx
,jax
andmatplotlib
's Sphinx directive altogether. The error was quite hard to pinpoint, and it is still quite vague to me, even after taking a look at the 7.2 release notes.I think the issue comes from the Sphinx side, because changing the version requirements to
Sphinx<7.2
fixed it all. Usingpip freeze
, there was no other relevant package that could cause this issue (to my understanding). This is why I post the issue in this repository, but please tell me if I just rather put it elsewhere.How to Reproduce
This is not a real MWE, but the issue happened on my repo (https://github.com/jeertmans/DiffeRT2d), which you can see the different between this commit (not working) to this commit (working).
Build logs are available here for the failing version:
logs_281.zip
Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: