Python Best Practices Type-First Development Types define the contract before implementation. Follow this workflow: 1. Define data models - dataclasses, Pydantic models, or TypedDict first 2. Define function signatures - parameter and return type hints 3. Implement to satisfy types - let the type checker guide completeness 4. Validate at boundaries - runtime checks where data enters the system Make Illegal States Unrepresentable Use Python's type system to prevent invalid states at type-check time. Dataclasses for structured data: Discriminated unions with Literal: NewType for domain primitiv…