Typing and annotation

Variable

Any variable could be annotated by : operator like:

# Original
var = value

# Annotation
var: TYPE = value

Function

def foo(a, b, c=False, d = None):
    ...

could become more readable in

def foo(a: int, b: str, c: bool = False, d: None = None) -> str:
    ...

Note

When using default value without annotation in function, no space around = is recommended. However, it is recommended when using annotation. Check PEP8 and PEP3107.

Class

class C:
    id
    counter

will become

class C:
    id: int
    name: str = 'Picard'