Open The-Compiler opened 8 years ago
Is that PEP484 link really laggy for you when scrolling? Also, your text above is a pretty good repro of #1182 Issues within issues...
It's a bit laggy, but not very bad - blame QtWebEngine for that one :wink:
This is was blocked by #637.
https://github.com/python/typing/issues/310#issuecomment-293340873 looks useful too
PyAnnotate sounds interesting - though someone™ would need to add Python 3 style annotation support to it.
MonkeyType seems awesome!
mypy now supports PEP 571, which means it'd be possible to release type hints for PyQt rewritten so they actually work with MyPy.
mypy is now running on Travis CI! There's still a long way to go as not much code is annotated right now, but it's a good start.
qutebrowser is now using mypy's check_untyped_defs
, which means it checks the entire codebase, even where there aren't any type annotations yet.
This requires quite some # type: ignore
comments (~140 at the time of writing), mainly due to issues with PyQt5-stubs. I expect those to go down again in the future, as those issues can be fixed there (or even upstream in PyQt5).
I'll update the original post with some more TODO items about things I've learned along the way.
Might be interesting to use diff-cover to enforce any new code to have type annotations.
See https://github.com/pytest-dev/pytest/pull/6486 for an example.
edit: I added tox -e mypy-diff
now - not using it on CI by default since there are a lot of WIP PRs still, but I'll probably turn it on at some point.
Also note that mypy has a pretty nice HTML report feature nowadays - if you run tox -e mypy -- --html-report mypy-html
and look at mypy-html/index.html
, you will get a list of files needing work:
The ones marked in red are places which likely will need more work (and probably don't have type annotations at all yet).
As mypy seems a lot more usable than when I last looked at it, maybe qutebrowser should start using PEP484 type hints.
PyQt 5.6 also comes with
.pyi
files for the whole PyQt, so that might already be beneficial before starting to annotate qutebrowser source.check_untyped_defs
runningtyping.
prefix and import things fromtyping
instead# FIXME:typing
comments