remove pytype from 'make check', and split up dev deps

This commit is contained in:
Damien Elmes 2019-12-22 08:56:47 +10:00
parent 079a00653e
commit 5075fc23f6
4 changed files with 34 additions and 21 deletions

View File

@ -11,7 +11,7 @@ jobs:
- python: 3.6 - python: 3.6
script: make -j 4 pytest pylint pytype script: make -j 4 pytest pylint pytype
- python: 3.7 - python: 3.7
script: make -j 4 check script: make -j 4 check pytype
notifications: notifications:
email: email:

View File

@ -54,15 +54,31 @@ uninstall:
# Prerequisites # Prerequisites
###################### ######################
REQS := .build/pyrunreqs .build/pydevreqs .build/jsreqs REQS := .build/pyrunreqs .build/jsreqs
.build/pyrunreqs: requirements.txt .build/pyrunreqs: requirements.txt
pip install -r $< pip install -r $<
./tools/typecheck-setup.sh ./tools/typecheck-setup.sh
touch $@ touch $@
.build/pydevreqs: requirements.dev .build/pytest-deps:
pip install -r $< pip install nose mock
touch $@
.build/mypy-deps:
pip install mypy==0.750
touch $@
.build/pylint-deps:
pip install pylint
touch $@
.build/pyimport-deps:
pip install isort
touch $@
.build/pytype-deps:
pip install pytype
touch $@ touch $@
.build/jsreqs: ts/package.json .build/jsreqs: ts/package.json
@ -108,30 +124,30 @@ run: build
###################### ######################
.PHONY: check .PHONY: check
check: mypy pyimports pytest pylint pytype checkpretty check: mypy pyimports pytest pylint checkpretty
# Checking python # Checking python
###################### ######################
PYCHECKDEPS := $(BUILDDEPS) $(shell find anki aqt -name '*.py' | grep -v buildhash.py) PYCHECKDEPS := $(BUILDDEPS) $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
.build/mypy: $(PYCHECKDEPS) .build/mypy: .build/mypy-deps $(PYCHECKDEPS)
mypy anki aqt mypy anki aqt
touch $@ touch $@
.build/pytest: $(PYCHECKDEPS) .build/pytest: .build/pytest-deps $(PYCHECKDEPS)
./tools/tests.sh ./tools/tests.sh
touch $@ touch $@
.build/pylint: $(PYCHECKDEPS) .build/pylint: .build/pylint-deps $(PYCHECKDEPS)
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 anki aqt pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 anki aqt
touch $@ touch $@
.build/pytype: $(PYCHECKDEPS) .build/pytype: .build/pytype-deps $(PYCHECKDEPS)
pytype --config pytype.conf pytype --config pytype.conf
touch $@ touch $@
.build/pyimports: $(PYCHECKDEPS) .build/pyimports: .build/pyimport-deps $(PYCHECKDEPS)
isort -rc anki aqt --check # if this fails, run 'make fixpyimports' isort -rc anki aqt --check # if this fails, run 'make fixpyimports'
touch $@ touch $@

View File

@ -49,14 +49,17 @@ avoid 'Any' when a proper type is impractical.
When adding type signatures, please avoid refactoring the code, as this is When adding type signatures, please avoid refactoring the code, as this is
liable to break add-ons or introduce regressions. liable to break add-ons or introduce regressions.
Anki's Makefile invokes two type checkers - mypy and pytype. Mypy is fast, but When running 'make check', Anki uses mypy to typecheck the code. Mypy is fast,
not very good at type inference, so it is mostly useful for checking code but not very good at type inference, so it is mostly useful for checking code
that has type signatures. It is able to read the bundled Qt stubs, and works that has type signatures. It is able to read the bundled Qt stubs, and works
across the whole Anki codebase. across the whole Anki codebase.
pytype is much slower, but is better able to infer types when typing hints When you use 'make pytype', Anki will typecheck the code with pytype. Pytype
are unavailable. It is not able to check the aqt/* code, as it can't read is much slower, but it can catch errors in untyped code that mypy misses. It
the Qt stubs, and it is not currently compatible with Python 3.8. is not able to check the aqt/* code, as it can't read the Qt stubs, and it is
not currently compatible with Python 3.8. It can also be difficult to build,
so it is not included in the default 'make check', but it will be run when a
pull request is submitted.
The Qt stubs are not perfect, so you'll find when doing things like connecting The Qt stubs are not perfect, so you'll find when doing things like connecting
signals, you may have to add the following to the end of a line to silence signals, you may have to add the following to the end of a line to silence

View File

@ -1,6 +0,0 @@
nose
mypy==0.750
pylint
mock
pytype
isort