Skip to main content
🏷️
PEP 484 · Speedrun · Python 3.5 (2015)

PEP 484 in 90 seconds — type hints, without TypeScript-envy

Python stays dynamic — but you can opt into typing.

Python is duck-typed. PEP 484 (2015) added an **optional** syntax for declaring types: ```python # Before def add(a, b): return a + b # After PEP 484 def add(a: int, b: int) -> int: return a + b ``` The interpreter ignores hints at runtime. So why did everyone adopt them?

Because the ecosystem grew teeth around them: - **mypy** flags type errors before runtime - **VS Code / PyCharm** use them for autocomplete + jump-to-definition - **Pydantic v2** validates incoming data at runtime - **FastAPI** generates OpenAPI docs and request parsers from them Python stays dynamic; tooling makes it feel typed.

Before — no hints (still valid Python)
def greet(name, times):
    # Is name a str? a list? a number?
    # Is times an int? Required? Optional?
    # The function works; the reader has to guess.
    return name * times
After — with PEP 484 hints
def greet(name: str, times: int = 1) -> str:
    # Reader (and mypy, and your IDE) know:
    # - name is a string
    # - times is an int, defaults to 1
    # - the function returns a string
    return name * times

🎯 Predict the output

What does this print? Pay attention — Python ignores hints at runtime.

def add(a: int, b: int) -> int:
    return a + b

print(add("foo", "bar"))
print(add(2, 3))
Type hints in context → Foundations track

Or speedrun another PEP

PEP 8Most of PEP 8 is decoration. Five rules carry the weight.
PEP 8 in 90 seconds — the style rules that actually matter
PEP 695Generic functions and classes, finally readable.
PEP 695 in 90 seconds — generic types without TypeVar
PEP 657From 'somewhere on this line' to 'this exact `[0]`'.
PEP 657 in 90 seconds — tracebacks that point at the actual sub-expression