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: Don't conflate passed argument with class member (instance attribute) #357

Open
pawamoy opened this issue Feb 2, 2025 · 1 comment
Assignees
Labels
bug Something isn't working top-priority Absolute priority

Comments

@pawamoy
Copy link
Member

pawamoy commented Feb 2, 2025

Description of the bug

In __init__ methods, when we do for example:

def __init__(self, arg: str) -> None:
    self.arg: str = arg
    """Description."""

Then Griffe thinks the arg value is the arg member, which it is not. It is an argument value, not a member of the current class.

This is annoying once docs are rendered, as the value will cross-reference to the member itself. The upcoming backlinks feature also suffers from it and will render a "used by" link pointing to itself.

Expected behavior

Griffe / mkdocstrings should not link such instance attribute values this way. I suppose it needs special casing somewhere 🤔

@pawamoy pawamoy added the bug Something isn't working label Feb 2, 2025
@pawamoy pawamoy self-assigned this Feb 2, 2025
@pawamoy pawamoy changed the title bug: Don't conflate passed argument with scope variable bug: Don't conflate passed argument with class member (instance attribute) Feb 2, 2025
@pawamoy
Copy link
Member Author

pawamoy commented Feb 3, 2025

Oh, I think this is causing a lot of "Multiple secondary URLs" warnings from autorefs too. For example in https://mkdocstrings.github.io/griffe/reference/api/checks/#griffe.AttributeChangedValueBreakage.details the value is resolved as a name with a canonical path of _griffe.diff.Breakage.details, which has no primary URL and multiple secondary URLs.

@pawamoy pawamoy added the top-priority Absolute priority label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working top-priority Absolute priority
Projects
None yet
Development

No branches or pull requests

1 participant