Add missing type annotations
This would be a great area for contributions. Ie. if you're looking to just start getting involved in the project, then...
- Run
venv/bin/mypy apistar tests --ignore-missing-imports --disallow-untyped-defs - Pick one of the modules (in
apistar, rather than in thetestsdirectory, at least for now) - Go through and see if you can add all the missing type annotations for that module.
- Make a pull request! 🚀
If you do want to take this on, then only add type annotations for a single module in any one pull request. (Rather than making a big pull request which affects multiple modules)
— ⭐️ —
In due course we could consider adding --disallow-untyped-defs to our mypy checking of the project.
This'd give us: venv/bin/mypy apistar tests --ignore-missing-imports --disallow-untyped-defs
Doing so would force us to add type annotations everywhere within apistar itself.
There are some test cases where we deliberately don't want to use this, as we're eg. checking functionality that occurs when eg. an untyped view is used, so we'd want to turn it off in those cases. (Or alternatively that might not be something we want to support anyways, and we enforce that handled views in API Star are always typed?)
So, question:
- What's the comment directive for turning that functionality off on a line-by-line basis? Is there one?
@tomchristie does this help?
@tomchristie mypy.ini lets you specify mypy directives on a per-module basis using pattern matches which seems like it would allow setting disallow-untyped-defs for a specific test module.
@weargoggles That's neat. We might end up wanting to eg. have strict type defs throughout the codebase, but not in the tests.
For now we've still got plenty of outstanding annotations to add in the codebase, before we think about tightening up the policy.
I think most annotations that are easy to catch / don't require deeper code changes are done now.
Most of the remaining complaints by mypy are in tests or eg. the missing return type of the build() methods (#116)
Taking on the schema module. Will try to add as much type annotations as possible. And maybe will take on some of the the TODOs after the PR related to type annotations are done.
What do you think @tomchristie ?
I don't think we need an open ticket for this right now, instead just treat it as a general code-quality aspect, and fix things up wherever possible along the way.