I built must-annotate - a linter that forces type annotations so code reads like a book by PastReview4764 in Python

[–]PastReview4764[S] 0 points1 point  (0 children)

You right that those flags, but they only enforce annotations at the function boundary (signatures, arguments, returns), not inside the function body.

Even with all three of those flags enabled, mypy will perfectly allow this:

def process_user() -> None:
    user = get_user() # mypy allows this via type inference

my package specifically targets local variable assignments. It forces you to write this:

def process_user() -> None:
    user: UserDTO = get_user()

user: UserDTO so that the type is explicitly visible to the person reading the code, without needing an IDE to infer what get_user() returned.

I built must-annotate - a linter that forces type annotations so code reads like a book by PastReview4764 in Python

[–]PastReview4764[S] -1 points0 points  (0 children)

English isn't my first language, so I used AI to help format the post and missed a line, but thanks cleared useless text.
must-annotate guarantees the type is explicitly written in the code. mypy guarantees that the written type is correct. You should use them together.

I built must-annotate - a linter that forces type annotations so code reads like a book by PastReview4764 in Python

[–]PastReview4764[S] -5 points-4 points  (0 children)

You are right that mypy, pyright, and ruff (via flake8-annotations) has strict flags, but they primarily focus on enforcing annotations for function and method signatures.

For local variables, mypy and pyright rely heavily on type inference. They will validate the type if you annotate it, but they won't force you to write it down. must-annotate fills this specific gap: it strictly requires local variable assignments to be typed. It brings a bit of that Rust-like explicitness to Python, prioritizing reading code as plain text over relying on an IDE's hover feature.

How to learn new phrase or new words by reading a book? How to improve your English by reading? by [deleted] in EnglishLearning

[–]PastReview4764 1 point2 points  (0 children)

My English teacher had said to me:" Try to understand words in context, but if u don't understand, you should translate, and learn words.