Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Yields broken for properties #298

Closed
michprev opened this issue Jun 27, 2024 · 1 comment
Closed

bug: Yields broken for properties #298

michprev opened this issue Jun 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@michprev
Copy link

Description of the bug

griffe complains with No type or annotation for yielded value 1 when using Yields: together with properties.

Both removing @property or changing Yields: to Returns: works but results in different code or rendered docs.

To Reproduce

@property
def children(self) -> Iterator[EnumValue]:
    """
    Yields:
        Direct children of this node.
    """
    yield from self._values

where

_values: List[EnumValue]

Full traceback

Relevant info:

WARNING -  griffe: wake/ir/declarations/contract_definition.py:357: No type or annotation for yielded value 1
WARNING -  griffe: wake/ir/declarations/enum_definition.py:109: No type or annotation for yielded value 1
WARNING -  griffe: wake/ir/declarations/error_definition.py:94: No type or annotation for yielded value 1
...

Full log from mkdocs build -v:

log.txt

Expected behavior

griffe works with properties yielding values as expected.

Environment information

griffe --debug-info

- __System__: macOS-14.5-arm64-arm-64bit
- __Python__: cpython 3.12.2 (/Users/michal/.pyenv/versions/3.12.2/bin/python3.12)
- __Environment variables__:
- __Installed packages__:
  - `griffe` v0.47.0
@michprev michprev added the unconfirmed This bug was not reproduced yet label Jun 27, 2024
@pawamoy
Copy link
Member

pawamoy commented Jun 27, 2024

Hi @michprev, thanks for the report.

It's actually the first time (I think) that I encounter a property that is also a generator 😄 Mind blown a bit!

I suppose the issue comes from the fact that when we parse a Yields section, we expect the parent to be a function and not an attribute. It should be easy to fix 🙂

@pawamoy pawamoy added bug Something isn't working and removed unconfirmed This bug was not reproduced yet labels Jun 27, 2024
pawamoy added a commit that referenced this issue Aug 9, 2024
@pawamoy pawamoy closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants