6 Matching Annotations
- Jan 2023
-
news.ycombinator.com news.ycombinator.com
-
Here's my opinion, having written many thousands of lines of mypy code.
Negative opinion on mypy (see below this annotation)
-
- Oct 2021
-
sadh.life sadh.life
-
TypedDict is a dictionary whose keys are always string, and values are of the specified type. At runtime, it behaves exactly like a normal dictionary.
TypedDict
-
you should only use reveal_type to debug your code, and remove it when you’re done debugging.
Because it's only used by mypy
-
What this says is “function double takes an argument n which is an int, and the function returns an int.
def double(n: int) -> int:
-
This tells mypy that nums should be a list of integers (List[int]), and that average returns a float.
from typing import List def average(nums: List[int]) -> float:
-
for starters, use mypy --strict filename.py
If you're starting your journey with mypy, use the --strict flag
-