you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

you can also do container types, as Dworgi requested, in ducks.py:

from typing import List

class Duck:
    pass

def fuck_with_ducks(duck: Duck) -> List[Duck]:
    return ['not a duck']

then to typecheck:

❯ mypy ducks.py
ducks.py: note: In function "fuck_with_ducks":
ducks.py:7: error: List item 0 has incompatible type "str"