[Python] How to use the type of another method's parameter as the type of my method's...

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    If I have something like this:

    def _process(img: str | List[str] | ndarray[_AnyShape, dtype[Any]] | List[ndarray[_AnyShape, dtype[Any]]]) -> None:
    …

    type TextInputs = ???

    def process(img: TextInputs) -> None:
    _process(img)



    Where _process is defined in a 3rd party module and imported, how would I define TextInputs to be the type of the img argument to _process?

    Continue reading...

Compartilhe esta Página