Conflict
I like two things:
- Type annotations in Python
- less code
Both conflict.
Imagine you have a big code base which uses the django framework.
In my code are about 200 methods with a request
argument.
Goal
Adding the type annotation to each methods without bloating the code.
I want annotations to have better auto completion in IDEs. Maybe (later) type testing in automated tests.
My current idea: Type annotations at package level:
in setup.py (or somewhere else) I define: every time the variable
request
gets used, it is of typedjango.http.HttpRequest
This would give me type annotations and less code than adding the type annotations 200 times.
For edge cases where the variable with the name request
points to a different type, explicit annotations should be done. But there are very few.
Question
How to get to the goal?
Background: I don't care for my current idea, I care for the goal.
Aucun commentaire:
Enregistrer un commentaire