Typing

Explicit method overriding with @typing.override

Catch method override errors at type-check time with Python's @override decorator from PEP 698, preventing typos and signature mismatches.

TypeIs does what I thought TypeGuard would do in Python

Understand TypeIs vs TypeGuard in Python: TypeIs provides more intuitive type narrowing by narrowing both positive and negative branches.

Annotating args and kwargs in Python

Properly annotate Python *args and **kwargs with heterogeneous types using Unpack, TypedDict, and modern type hints from PEP-692.

Statically enforcing frozen data classes in Python

Enforce immutable dataclasses at type-check time with @final decorator to catch mutations before runtime without frozen=True performance cost.

Guard clause and exhaustiveness checking

Master TypeScript's never type and Python's NoReturn for exhaustiveness checking. Flatten nested conditionals with guard clauses for cleaner code.

Declarative payloads with TypedDict in Python

Use Python TypedDict to declaratively define API payload structures. Get type safety for nested dictionaries and improve code maintainability.

Self type in Python

Use Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.

Narrowing types with TypeGuard in Python

Use Python's TypeGuard to create custom type narrowing functions that help static type checkers understand runtime type checks and validations.

Why 'NoReturn' type exists in Python

Use Python's NoReturn type to annotate functions that never return normally, helping type checkers understand exception-raising and infinite loop code.

Go Rusty with exception handling in Python

Implement Rust-style Result types for type-safe exception handling in Python using generic Ok and Err types inspired by Black formatter.

Variance of generic types in Python

Understand covariance, contravariance, and invariance in Python generics with practical examples of type relationships and subtyping rules.

Static typing Python decorators

Type Python decorators accurately using ParamSpec and Concatenate to preserve wrapped function signatures and enable proper static analysis.

Difference between constrained 'TypeVar' and 'Union' in Python

Understand when to use constrained TypeVar vs Union in Python type hints for consistent types across function parameters and return values.

Structural subtyping in Python

Implement Go-style structural subtyping in Python with Protocol for duck typing and interface-based APIs without inheritance dependencies.