Browse by Topic

Popular

Latest

Latest Posts

Illustration of a Python function with multiple type signature cards, each leading to a different return type, symbolizing the overload decorator.
Python

Python Overload Decorator: Multiple Type Signatures

Learn how to use Python's @overload decorator to define multiple type signatures, improving static type checking and code clarity.

typingtype-hintsoverloadstatic-typing
Illustration of a Python TypedDict representing a structured dictionary with typed keys and values, shown as a labeled document with type annotations.
Python

Python TypedDict: Typed Dictionaries in Practice

python typeddict: How to declare typed dictionaries with Python TypedDict, how type checkers enforce keys and values, and when to choose it over dataclass or NamedTuple.

TypedDictType HintsStatic Typingmypy
Illustration of a Python dictionary with type annotations for keys and values, representing a typed dict.
Python

Python TypedDict: Defining Type-Safe Dictionaries

Learn how to use Python's TypedDict to declare dictionary shapes for static type checkers, improving type safety and maintainability.

typingdictionariestype hintsmypy
Illustration of Python code with type annotations and a mypy check icon.
Python

Python Annotated Types: Syntax, Runtime Behavior, and Tooling

Learn how Python annotated types work: syntax examples, runtime behavior, and static type checking with mypy.

pythontype hintsannotationstyping module
Diagram showing a class variable shared across instances in Python
Python

Python ClassVar: Class Variables Explained

python classvar: Understand Python class variables, how they differ from instance variables, and when to use them without introducing shared-state bugs.

class variablesinstance variablesPython OOPshared state
Python code editor showing a Final type hint annotation on a variable, with a lock icon representing immutability for static type checkers.
Python

Python Final Type Hint: Usage and Limitations

Learn how Python's Final type hint signals non-reassignment to static type checkers, what it does at runtime, and where it falls short.

typingstatic analysismypyPEP 591
Illustration of a Python function parameter restricted to a small set of literal string values.
Python

Python Literal Type: Restricting Values with typing.Literal

Python's typing.Literal restricts a value to a fixed set. See how type checkers enforce it, how to combine it with unions and overloads, and when runtime validation is still needed.

typingtype hintsmypystatic analysis
Illustration of Python NewType creating distinct types from a base type, shown as a type-checking shield over primitive values.
Python

Using Python NewType for Type Safety

Python's NewType creates distinct types for static type checking. This article explains its runtime behavior, how it differs from subclassing, and when to use it.

typingtype hintstype safetymypy
Illustration of a Python type alias mapping a complex type expression to a simple name like UserID.
Python

Python TypeAlias: Syntax, Usage, and Practical Examples

Learn how to declare and reuse Python type aliases with the type statement and typing.TypeAlias, including practical examples and when to prefer them over NewType.

PythonType HintsTypeAliasNewType
Illustration of a Python type alias concept showing a complex type annotation being replaced by a clear alias name.
Python

Python Type Alias: Cleaner Type Hints

python type alias: Learn how to define and use type aliases in Python to simplify complex annotations, improve readability, and keep type hints maintainable.

type hintstypingmypycode maintainability