I believe there might be an issue when using pytreeclass with Sphinx >=9.0. Whenever I try to use this combination, I get the following error:
Traceback
=========
Traceback (most recent call last):
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/util/inspect.py", line 547, in object_description
s = repr(obj)
^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/pytreeclass/_src/code_build.py", line 161, in __repr__
attrs = [f"{k}={getattr(self, k)!r}" for k in slots(Field)]
^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/pytreeclass/_src/code_build.py", line 161, in __repr__
attrs = [f"{k}={getattr(self, k)!r}" for k in slots(Field)]
^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/pytreeclass/_src/code_build.py", line 161, in __repr__
attrs = [f"{k}={getattr(self, k)!r}" for k in slots(Field)]
^^^^^^^^^^^^^^^^^^^^
[Previous line repeated 2972 more times]
RecursionError: maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/cmd/build.py", line 432, in build_main
app.build(args.force_all, args.filenames)
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/application.py", line 442, in build
self.builder.build_update()
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 381, in build_update
self.build(
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 409, in build
updated_docnames = set(self.read())
^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 525, in read
self._read_serial(docnames)
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 590, in _read_serial
self.read_doc(docname)
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 653, in read_doc
doctree = _parse_str_to_doctree(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/util/docutils.py", line 902, in _parse_str_to_doctree
parser.parse(content, document)
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/parsers.py", line 99, in parse
self.statemachine.run(inputlines, document, inliner=self.inliner)
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 182, in run
results = StateMachineWS.run(self, input_lines, input_offset,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/statemachine.py", line 234, in run
context, next_state, result = self.check_line(
^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/statemachine.py", line 446, in check_line
return method(match, context, next_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2487, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2499, in explicit_construct
return method(self, expmatch)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2236, in directive
return self.run_directive(
^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2286, in run_directive
result = directive_instance.run()
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/ext/autodoc/_directive.py", line 99, in run
content = _auto_document_object(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/ext/autodoc/_generate.py", line 45, in _auto_document_object
props = _load_object_by_name(
^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/ext/autodoc/_dynamic/_loader.py", line 97, in _load_object_by_name
props = _make_props_from_imported_object(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/ext/autodoc/_dynamic/_loader.py", line 457, in _make_props_from_imported_object
_obj_repr_rst=inspect.object_description(obj),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mahlau/nobackup/fdtdx/.venv/lib/python3.12/site-packages/sphinx/util/inspect.py", line 549, in object_description
raise ValueError from exc
ValueError
Since you also seem to be using sphinx for documentation, could you check if you encounter similar problems?
Hi @ASEM000,
I believe there might be an issue when using pytreeclass with Sphinx >=9.0. Whenever I try to use this combination, I get the following error:
Since you also seem to be using sphinx for documentation, could you check if you encounter similar problems?
Many thanks!