Proposed Outline:
- Common pitfalls of Python dynamic typing, delayed code failure, bad user experiences, and difficult-to-find bugs
- Explain what Pydantic is and how it can help to solve the problem
- Give a high level overview of Pydantic's key features and main use in web applications
- Provide step-by-step instructions for installing Pydantic
- Check if Pydantic is installed correctly
- Pydantic v2.0 vs. v1.x. If available we will use Pydantic v2.0
- Refresher on Python type annotations and class definitions
- Creation of a simple Pydantic model
- Initializing models and setting model attributes
- Overview of common “atomic” types, such as float, int, str, bool, etc.
- Type parsing (without validation)
- Default values, optional values and Optional type
- Model Config and Config.extra = “forbid”
- More complex data types, such as typed lists and dictionaries
- Working with Enums and Union types
- Working with datetime types
- Defining custom data types
- Building hierarchical structures / recursive models
- Defining private attributes via ClassVar, PrivateAttr and Config
- Validators and validation functions
- Pre and post init validation
- Root validators
- Introduce validate_arguments decorator
- Skip validation and .construct() method
- Config settings related to validation
- Refresher on builtin Python data structures
- Model creation from NamedTuple, TypedDict or dataclasses
- Dynamic model creation using create_model
- Motivate need for serialization and deserialization of Python objects, Why not just pickle?
- Introduce JSON / YAML formats, also mention TOML
- Serialize Pydantic model to and from JSON / YAML
- Introduce .dict() and .json()
- Implementing JSON encoders for custom types
- Fields and extending schema definitions
- Config of serialization, excluding and including fields
- Performance remarks for serialization
- Nick to work on interface with web API
- Axel to work on interface with configuration file (i.e. build and compare simple models)
- Mention Pycharm, VSCode, MyPy plugins etc.
- Show best practices for using Pydantic in projects
- List common mistakes and pitfalls
- Summarize of key takeaways from the tutorial
- List additional resources for learning Pydantic