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

Fails to recognize optional arguments in NamedTuple #165

Closed
OpenBagTwo opened this issue May 24, 2023 · 2 comments
Closed

Fails to recognize optional arguments in NamedTuple #165

OpenBagTwo opened this issue May 24, 2023 · 2 comments

Comments

@OpenBagTwo
Copy link

OpenBagTwo commented May 24, 2023

Summary

NamedTuples with optional / default values still show as "required"

Environment and Version

  • Python 3.11.3, running on Linux x86-64
  • mkdocs=1.4.3=pyhd8ed1ab_0
  • mkdocs-autorefs=0.4.1=pyhd8ed1ab_1
  • mkdocs-material=9.1.12=pyhd8ed1ab_0

Steps to Reproduce

Since Python 3.7 (I think?) one can define a NamedTuple with default values as so:

from typing import NamedTuple


class Example(NamedTuple):
    """A simple example of the autorefs bug

    Parameters
    ----------
    required : int
        A required value
    optional : float, optional
        An optional value, default is -3.6
    """

    required: int
    optional: float = -3.6

which behaves as follows:

>>> Example(2)
Example(required=2, optional=-3.6)

Rendering this code with mkdocstrings-python results in the following:
Screengrab from mkdocs output

Workaround

Not that I've been able to figure out (besides just not using NamedTuple)

Severity

Annoying.

Desired Outcome

Fix

Urgency

None

@pawamoy pawamoy transferred this issue from mkdocstrings/autorefs May 24, 2023
@pawamoy pawamoy changed the title Autorefs fails to recognize optional arguments in NamedTuple Fails to recognize optional arguments in NamedTuple May 24, 2023
@pawamoy
Copy link
Member

pawamoy commented May 24, 2023

Hey, thanks for the report. I've moved it to the Griffe repo and edited the title and body accordingly. Will investigate asap.

@pawamoy
Copy link
Member

pawamoy commented Jun 19, 2023

Should be fixed, will release soon 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants