Describe the bug
In cssutils, I've stumbled into an issue where the docs builds are failing (jaraco/cssutils#36).
After some investigation, I learned that the issue seems to be related to the use of autodoc with autodoc_preserve_defaults = True and the use of property(lambda) where the lambda is on a different line from the property.
How to Reproduce
draft $ cat mod.py
class X:
foo = property(
lambda self: None, doc="Foo.")
draft $ cat conf.py
extensions = [
'sphinx.ext.autodoc',
]
master_doc = "index"
# Preserve authored syntax for defaults
autodoc_preserve_defaults = True
draft $ cat index.rst
.. automodule:: mod
:members:
:undoc-members:
draft $ pip-run sphinx -- -m sphinx . build
Running Sphinx v7.0.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
WARNING: error while formatting arguments for mod.X.foo: Handler <function update_defvalue at 0x102c2b100> for event 'autodoc-before-process-signature' threw an exception (exception: unmatched ')' (<unknown>, line 2))
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex py-modindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.
The HTML pages are in build.
Environment Information
draft $ pip-run sphinx -- -m sphinx --bug-report
Please paste all output below into the bug report template
Platform: darwin; (macOS-13.4-arm64-arm-64bit)
Python version: 3.11.3 (main, Apr 7 2023, 20:13:31) [Clang 14.0.0 (clang-1400.0.29.202)])
Python implementation: CPython
Sphinx version: 7.0.1
Docutils version: 0.20.1
Jinja2 version: 3.1.2
Pygments version: 2.15.1
Sphinx extensions
Additional context
Weirdly, removing the carriage return after property( suppresses the error. Also, converting to a traditional @property decorator or replacing the lambda with a simple function also suppresses the error:
class X:
def _f(self):
return
foo = property(
_f, doc="Foo.")
Describe the bug
In cssutils, I've stumbled into an issue where the docs builds are failing (jaraco/cssutils#36).
After some investigation, I learned that the issue seems to be related to the use of
autodocwithautodoc_preserve_defaults = Trueand the use ofproperty(lambda)where the lambda is on a different line from theproperty.How to Reproduce
Environment Information
Sphinx extensions
Additional context
Weirdly, removing the carriage return after
property(suppresses the error. Also, converting to a traditional@propertydecorator or replacing the lambda with a simple function also suppresses the error: