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

Incorrect data type definition for attributes without annotation #110

Closed
dd opened this issue Sep 25, 2023 · 3 comments
Closed

Incorrect data type definition for attributes without annotation #110

dd opened this issue Sep 25, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dd
Copy link

dd commented Sep 25, 2023

If a method contains an attribute without an annotation among its attributes, the data type will be inherited from the previous one.

For example, this will actively occur for the *args and **kwargs attributes:

def foo(bar: str, *args, baz: bool=True, qux="quux", **kwargs):
    """
    Foo method
    """
    pass

image
Please note that the qux attribute also inherited the data type from the previous one

Expected behavior
I think it is obvious that the data type should not be inherited from the previous attribute.
I also think that for attributes like */** the default data type can be tuple and dict, respectively.

System (please complete the following information):

  • mkdocstrings-python: 1.7.0
  • Python version: 3.11
  • OS: Linux
@pawamoy
Copy link
Member

pawamoy commented Sep 25, 2023

Thanks for the report! It looks like Griffe is correctly collecting data, so I suspect the issue happens in the Python handler where loop variable isn't reset. I'll fix this ASAP 🙂

@pawamoy
Copy link
Member

pawamoy commented Sep 25, 2023

I also think that for attributes like /* the default data type can be tuple and dict, respectively.

Not really. *args and **kwargs are tuples and dicts respectively, sure, but tools expect to find their inner element type as annotation: *args: float or **kwargs: set[int]. It means we can't compute a default type annotation, and it will stay empty if the user didn't provide one.

@waylan
Copy link
Contributor

waylan commented Sep 27, 2023

I have seen this behavior as well. Looking forward to a fix.

@pawamoy pawamoy self-assigned this Sep 28, 2023
@pawamoy pawamoy added the bug Something isn't working label Sep 28, 2023
@pawamoy pawamoy closed this as completed Sep 28, 2023
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

3 participants