[Python] How to write type hints for a function returning itself?

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    from typing import Callable


    def f() -> Callable:
    return f


    How to explicitly define f's type? like Callable[[], Callable]

    I think it is slightly like a linked list, but I can't implement it.

    from typing import Union


    class Node:
    def __init__(self, val):
    self.val = val
    self.next: Union[Node, None] = None

    Continue reading...

Compartilhe esta Página