[Python] What would be the best option to render typing_extension.Self output type-hint as the...

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm looking for advice on how to best render typing_extensions.Self output type-hints, while keeping show_signature_annotations: true option enabled.

    mkdocstrings config follows:

    plugins:
    - mkdocstrings:
    handlers:
    python:
    import:
    - https://installer.readthedocs.io/en/stable/objects.inv
    rendering:
    show_signature_annotations: true
    options:
    members_order: alphabetical


    Would it be possible to translate typing_extensions.Self so as that Type is rendered by the class name rather than by the typing_extensions.Self type-hint? IOW,

    def func(self, arg: str) -> Self:
    """

    Arguments:
    arg: Argument.

    Returns:
    blah blah
    """


    would actually output

    [​IMG]

    while I would possibly like Type to output the class name. Alternatively, I would appreciate getting guidance on how to handle such situation; also, does anyone believe - otoh - it is reasonable for it to output Self?

    Can anyone advise? Don't know if anyone would consider this a plausible feature request, were this not possible.

    Continue reading...

Compartilhe esta Página