Cheatography
https://cheatography.com
MyPy Tool
mypy [files]
|
Command line to check syntax |
-v
|
Be Verbose |
-any-exprs-report PATH
|
Provide a path to generate a coverage report |
This tool will show you Type Errors found in the code. If verbose is off and the command returns nothing, the code is OK.
Type Definition
from typing import Dict, List, Tuple
|
Import types definition |
var: str = ""
|
Define str a variable |
var: Dict[str, int] = {}
|
Define Dict a variable |
var: Tuple[str, float, int] = ()
|
Define Tuple a variable |
MyType = Dict[str, int]
|
Define a custom 'Type` |
var: MyType = {}
|
Define MyType a variable |
def function(arg: str) -> int:
|
Define a function that takes an str and returns an int |
var: Any
|
The Any type accepts all types |
var: Union[str, int]
|
This Union type accepts either a str or an int |
pip install mypy
pip install typing
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by amicheletti