typing

Stdlib — TypingPython 3.5+Intermediate

Type hint support: List, Dict, Optional, Union, Any, Callable, Generic, Protocol

Quick Info

Documentation
Official Docs
Python Version
3.5+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

python
from typing import List, Dict, Optional, Union

def greet(name: str, times: int = 1) -> str:
    return f"Hello, {name}! " * times

def process(items: List[int]) -> Dict[str, int]:
    return {"sum": sum(items), "count": len(items)}

result = process([1, 2, 3, 4, 5])
print(result)

The typing module is part of Python's standard library. Type hint support: List, Dict, Optional, Union, Any, Callable, Generic, Protocol.

Try in Playground

Tags

stdlibtypingtype-hintsstatic-analysis

Related Items