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 PlaygroundTags
stdlibtypingtype-hintsstatic-analysis
Related Items
abc
Stdlib — Typing
Abstract Base Classes: define interfaces subclasses must implement
dataclasses
Stdlib — Data
Decorator for auto-generating class boilerplate (__init__, __repr__, etc.)
pydantic
Package — Validation
Data validation using Python type annotations; settings management
mypy
Package — Code Quality
Static type checker for Python type annotations
pyright
Package — Code Quality
Fast type checker by Microsoft (VS Code Pylance)
typing_extensions
Stdlib — Typing
Backports of new typing features for older Python versions