This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An example of how deep python annotations can go. | |
Here I show a possible way to annotate an add() function to account for as many cases as possible. | |
We assume that the add() function simply adds the two numbers and does not call internal __add__ or __radd__ methods. | |
""" | |
from typing import Protocol, overload | |
T_contra = TypeVar('T_contra', contravariant=True) | |
T_co = TypeVar('T_co', covariant=True) |