https://docs.python.org/3/library/typing.html
Int
length: int
length: int = 10
Float
width: float
width: float = 100
Strings
name: str
name: str = "rectangle"
Boolean
is_square: bool
is_square: bool = False
- ordered
- changeable
- allow duplicate values
x: List[int] = [1, 2]
a: List[float] = [1.0, 4.6, 9.1]
- ordered*
- changeable
- not allow duplicates.
- Python 3.7 dictionaries are ordered, Python 3.6 and earlier dictionaries are unordered
x: Dict[str, float] = {'length': 10.0, 'width': 100.0}
- collections
- unordered
- unindexed
x: Set[str] = {'rect', 'square'}
- ordered
- unchangeable
x: Tuple[str, float, float] = ("rect", 10.0, 100.0)
a: Any
a = None # type: Any
a = [] # OK
a = 2 # OK
def add_two_integers_or_floats(x: Union[int, float], y: Union[int, float]) -> Union[int, float]:
return x + y
aux : Optional[str]: #Union[X, None]
aux = None
F = List[float] # Aliasing list of floats
a: F = [1.0, 4.6, 9.1]