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: unsupported node #316

Closed
slyons opened this issue Aug 21, 2024 · 6 comments
Closed

bug: unsupported node #316

slyons opened this issue Aug 21, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@slyons
Copy link

slyons commented Aug 21, 2024

Description of the bug

I'm trying to generate some documentation using mkdocstrings for a Rust/pyo3 project but am not able to due to the bug.

To Reproduce

git clone https://github.com/slyons/szurubooru-client
git switch dev/pylib
cd szurubooru-client-docs
./build.sh
griffe dump szurubooru_client -o/dev/null -LDEBUG

Full traceback

Full traceback
INFO       Loading package szurubooru_client
DEBUG      Searching path(s) for szurubooru_client
DEBUG      Found szurubooru_client: loading
DEBUG      Loading path /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/__init__.py
DEBUG      Loading path /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/szurubooru_client.cpython-312-darwin.so
DEBUG      Loading path /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/models.py
DEBUG      Failed to extract `__all__` value: szurubooru_client.models.__all__ at /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/models.py:34: unsupported node <class 'ast.Attribute'>
DEBUG      Loading path /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/tokens.py
DEBUG      Failed to extract `__all__` value: getattr(_tokens, '__all__') at /opt/dev/projects/szurubooru-client/szurubooru-client/szurubooru_client/tokens.py:23: unsupported node <class 'ast.Call'>
INFO       Finished loading packages

Expected behavior

I expected that the documentation would build successfully

Environment information

griffe --debug-info  # | xclip -selection clipboard
  • System: macOS-14.6-arm64-arm-64bit
  • Python: cpython 3.12.5 (/Users/slyons/.pyenv/versions/3.12.5/envs/szurubooru-client/bin/python)
  • Environment variables:
  • Installed packages:
    • griffe v1.1.1

Additional context

@pawamoy
Copy link
Member

pawamoy commented Aug 22, 2024

Hi @slyons, thank you for the report!

Valid bug, Griffe doesn't support attributes when expanding __all__. Let me work on this asap 🙂

@pawamoy pawamoy added bug Something isn't working and removed unconfirmed This bug was not reproduced yet labels Aug 22, 2024
@pawamoy
Copy link
Member

pawamoy commented Aug 22, 2024

Note however that getattr(_tokens, '__all__') cannot be supported statically. Since there's no default value, maybe you could simply use _tokens.__all__ instead?

@pawamoy
Copy link
Member

pawamoy commented Aug 22, 2024

I'm not sure to understand how your code works:

from .szurubooru_client import _models

AroundPostResult = _models.AroundPostResult
...
UserResource = _models.UserResource

__doc__ = szurubooru_client.models.__doc__
if hasattr(szurubooru_client.models, "__all__"):
    __all__ = szurubooru_client.models.__all__

The module-level szurubooru_client name isn't defined here. Doesn't that raise a NameError for you?

@slyons
Copy link
Author

slyons commented Aug 22, 2024

For _models it definitely does (and I've fixed this in the branch). But the solution was to comment out the __all__ lines and Griffe was happy.

Sadly, mkdocstrings still can't find my modules no matter how hard I try.

pawamoy added a commit that referenced this issue Aug 23, 2024
@pawamoy pawamoy closed this as completed Aug 23, 2024
@pawamoy
Copy link
Member

pawamoy commented Aug 23, 2024

I'll let you know when I release a new version with this change, so you can tell me if it works better.

@pawamoy
Copy link
Member

pawamoy commented Aug 23, 2024

v1.2.0 is out, let me know if it works. If not, please open a new issue 🙂

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