python-attrs / python-attrs/attrs
slots + cached_property + sphinx
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Hi @hynek, great to see that version 24.1.0 is finally out, have been looking forward to it for quite a while 👍🏼 🙃
One reason why I was waiting for it is because I wanted to enable slots for our classes that rely on cached_property. After upgrading to 24.1.0 and activating slots, everything seemed to work fine ... except for our docs 😕
We build them with sphinx and the error I'm getting indicates trouble coming from exactly the cached_property part. Here is an excerpt from the critical class
@define(frozen=True)
class DiscreteParameter(Parameter, ABC):
@cached_property
@abstractmethod
def comp_df(self) -> pd.DataFrame: ...
for which I get the following error during our sphinx built
/home/runner/work/baybe/baybe/.tox/docs-py312/lib/python3.12/site-packages/baybe/parameters/base.py:docstring of baybe.parameters.base.DiscreteParameter.__init__:1:<autosummary>:1:py:obj reference target not found: baybe.parameters.base.DiscreteParameter.comp_df
I haven't yet tried to pull together a minimal self-contained example, because I first wanted to ask if you already have an idea what could cause the problem – perhaps the cached_property integration is simply not yet correct/complete?
All I can say for now is:
- it works when I disable the slots
- it works when I turn the
cached_propertyinto a regularproperty
so the issue really does seem to be related to the latests attrs changes.
Let me know if you need more information!
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
No project file or test is named. Start by reproducing the Sphinx build with slots and cached_property enabled, then compare it with slots disabled or a regular property. Done means the DiscreteParameter.comp_df reference resolves without the reported autosummary warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100