Describe the bug
In typing stubs, all type evaluation is deferred, but Sphinx seems to load typing stubs as if they were regular Python modules and then chokes when there are forward references.
WARNING: autodoc: failed to import 'types' from module 'coconext'; the following exception was raised:
Traceback (most recent call last):
File "/home/ktbarrett/dev/coconext/.venv/lib/python3.12/site-packages/sphinx/ext/autodoc/_dynamic/_importer.py", line 227, in _import_module
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/ktbarrett/dev/coconext/.venv/lib/python3.12/site-packages/coconext/types.pyi", line 17, in <module>
class Logic:
File "/home/ktbarrett/dev/coconext/.venv/lib/python3.12/site-packages/coconext/types.pyi", line 19, in Logic
def __init__(self, arg: Logic) -> None: ...
^^^^^
NameError: name 'Logic' is not defined
This was fixed by placing a from __future__ import annotations at the top of the offending file; however, this is redundant as typing stubs implicitly behave in this way.
The stub causing offense was generated by nanobind. I don't want to have to maintain some fixup script for this, so there's no current workaround for me.
How to Reproduce
git clone https://github.com/ktbarrett/coconext.git@438b84a9e02ffc69144ee04bc00ef35ce093dc9c
cd coconext
uv venv
source .venv/bin/activate
make docs
Environment Information
Sphinx extensions
Additional context
No response
Describe the bug
In typing stubs, all type evaluation is deferred, but Sphinx seems to load typing stubs as if they were regular Python modules and then chokes when there are forward references.
This was fixed by placing a
from __future__ import annotationsat the top of the offending file; however, this is redundant as typing stubs implicitly behave in this way.The stub causing offense was generated by nanobind. I don't want to have to maintain some fixup script for this, so there's no current workaround for me.
How to Reproduce
Environment Information
Sphinx extensions
"sphinx.ext.autodoc"Additional context
No response