Return type hints (-> …)
The arrow `-> type` after a `def`'s parentheses says what type of value the function returns.
Used in 90 lessons of the course, from 00.01.
In def define(term: str) -> None: the -> None part is the return type hint. Read it as: "define takes a string and returns nothing useful". It sits between the ) and the colon.
Python does not check it at runtime. If the function returns something else, there is no error. So why write it? Because it documents your intent right in the signature. Your editor and tools like mypy use it to warn you about mistakes before you run. LangChain and Pydantic also read these annotations to understand your functions.
-> None shows up a lot in the course. It marks a function that does something (like printing) instead of computing a value. Python stores the annotation in func.__annotations__["return"].
Reach for it when: you define any function, so readers (and your editor) know what it returns.
Examples
Common mistake
def greet(name: str) -> str:
print(f"Hi {name}")
message = greet("Ana")
print(message)Why: The signature promises a `str`, but the function prints instead of returning. Python doesn't enforce the hint, so `message` ends up as `None`.
How to write it: Use return f"Hi {name}" if you want the string, or change the hint to -> None if the function only prints.
