- Adding a type to a union or generic type
- Checking if a generic type has a given subtype
- Resolving a type annotation
See Type Annotations for a general overview of the type maninpulation
APIs for monitoring types
Codegen programs typically access type annotations through the following APIs: Each of these has an associated setter.Finding the extent of your type coverage
T to get an indication of your progress on type coverage, analyze the percentage of typed elements across your codebase- Function parameters - Arguments passed to functions
- Return types - Function return type annotations
- Class attributes - Type hints on class variables
Adding simple return type annotations
To add a return type, usefunction.set_return_type. The script below will add a -> None return type to all functions that contain no return statements: