diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ !packages/keys/ .venv +.mypy_cache diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ make -C doc/ check: $(patsubst %,check/%,$(PYMODULES)) +typecheck: $(patsubst %,typecheck/%,$(PYMODULES)) distclean: $(patsubst %,distclean/%,$(PYMODULES)) test: $(patsubst %,test/%,$(PYMODULES)) @@ -21,6 +22,8 @@ check/%: make -C $* check +typecheck/%: + make -C $* typecheck distclean/%: make -C $* distclean test/%: diff --git a/Makefile.python b/Makefile.python --- a/Makefile.python +++ b/Makefile.python @@ -14,6 +14,8 @@ FLAKEFLAGS = LINT = pylint3 LINTFLAGS = --rcfile=../pylintrc +MYPY = mypy +MYPYFLAGS = --config-file ../mypy.ini all: @@ -32,6 +34,9 @@ check-codespell: find swh docs -name '*.py' -o -name '*.rst' | xargs -r $(CODESPELL) $(CODESPELLFLAGS) find . -maxdepth 1 -iname 'readme*' | xargs -r $(CODESPELL) $(CODESPELLFLAGS) +typecheck: + @echo PYTHONPATH=... $(MYPY) $(MYPYFLAGS) -p $(PYMODULE) + @MYPYPATH=$(shell bash ../pythonpath.sh --print) $(MYPY) $(MYPYFLAGS) -p $(PYMODULE) .PHONY: check-staged check-staged: diff --git a/mypy.ini b/mypy.ini new file mode 100644 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,52 @@ +[mypy] +cache_dir = ../.mypy_cache +namespace_packages = True +warn_unused_ignores = True + + +# 3rd party libraries without stubs (yet) + +[mypy-aiohttp_utils.*] +ignore_missing_imports = True + +[mypy-azure.*] +ignore_missing_imports = True + +[mypy-arrow.*] +ignore_missing_imports = True + +[mypy-celery.*] +ignore_missing_imports = True + +[mypy-decorator.*] +ignore_missing_imports = True + +[mypy-deprecated.*] +ignore_missing_imports = True + +[mypy-libcloud.*] +ignore_missing_imports = True + +[mypy-msgpack.*] +ignore_missing_imports = True + +[mypy-pkg_resources.extern.*] +ignore_missing_imports = True + +[mypy-psycopg2.*] +ignore_missing_imports = True + +[mypy-pyblake2.*] +ignore_missing_imports = True + +[mypy-pytest.*] +ignore_missing_imports = True + +[mypy-rados.*] +ignore_missing_imports = True + +[mypy-request_mock.*] +ignore_missing_imports = True + +[mypy-systemd.*] +ignore_missing_imports = True