How should I do type annotations for a Python method that looks something like this?

def foo(
    self,
    param1, # type: int
    param2, # type: str
    ): # return type here?
     ...

Asking Josh about this (Josh Questions 202004240900 Josh Questions)

Answer: it should look like this:

def foo(
    self,
    param1, # type: int
    param2, # type: str
    ): 
    # type: (...) -> ReturnType
     ...

uuid: 202004250202 Specific kind of mypy type annotation date: Apr 25, 2020 tags: #python


Date
February 22, 2023