apistar icon indicating copy to clipboard operation
apistar copied to clipboard

Add missing type annotations

Open lovelydinosaur opened this issue 9 years ago • 6 comments

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 the tests directory, 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?

lovelydinosaur avatar Apr 20 '17 16:04 lovelydinosaur

@tomchristie does this help?

morrme avatar Apr 25 '17 07:04 morrme

@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 avatar Apr 25 '17 08:04 weargoggles

@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.

lovelydinosaur avatar Apr 25 '17 10:04 lovelydinosaur

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)

mammuth avatar Apr 28 '17 23:04 mammuth

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 ?

rcshubhadeep avatar May 02 '17 13:05 rcshubhadeep

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.

lovelydinosaur avatar Aug 17 '17 10:08 lovelydinosaur