sphinx-doc / sphinx-doc/sphinx
autodoc doesn't correctly document properties if getters/setters have different function names
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Methods with the @property decorator can have a different method name for the setter, like shown below:
@property
def username(self) -> str:
"""
:getter: gets username
:setter: sets username
"""
return self._username
@username.setter
def set_username(self, val: str) -> None:
self._username = val
They are the same property, and should be rendered as one like this:

But sphinx autodoc adds an extra property for the setter with the exact same docstring information when using autoclass:

How to Reproduce
$ git clone https://github.com/miaowware/callsignlookuptools.git
$ cd callsignlookuptools
$ pip install -r devrequirements.txt
$ cd docs
$ make html
$ # open _build/html/api.html and see the duplicate properties
Expected behavior
Only this property is shown in the docs:

Your project
https://github.com/miaowware/callsignlookuptools
OS
Void Linux
Python version
3.9.7
Sphinx version
4.0.3
Sphinx extensions
sphinx.ext.autodoc, sphinx_autodoc_typehints, sphinxcontrib.fulltoc, enum_tools.autoenum
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the duplicate-property output with the provided callsignlookuptools example: install devrequirements.txt, enter docs, and run make html. Investigate autodoc's handling of @property and differently named setter methods; done means autoclass renders the getter and setter as one property without duplicate documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100