From d2a8f15f582cd9eb602c4917aeb0d16a5a50e77b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli <zack@upsilon.cc> Date: Fri, 1 Nov 2019 12:22:40 +0100 Subject: [PATCH 1/2] typing: minimal changes to make a no-op mypy run pass --- .gitignore | 1 + mypy.ini | 21 +++++++++++++++++++++ swh/__init__.py | 5 ++++- swh/loader/__init__.py | 5 ++++- swh/loader/npm/py.typed | 1 + tox.ini | 10 +++++++++- 6 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 mypy.ini create mode 100644 swh/loader/npm/py.typed diff --git a/.gitignore b/.gitignore index f171835..430d19c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ version.txt build/ dist/ .tox/ +.mypy_cache/ diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..f5765bb --- /dev/null +++ b/mypy.ini @@ -0,0 +1,21 @@ +[mypy] +namespace_packages = True +warn_unused_ignores = True + + +# 3rd party libraries without stubs (yet) + +[mypy-chardet.*] +ignore_missing_imports = True + +[mypy-celery.*] +ignore_missing_imports = True + +[mypy-requests_mock.*] +ignore_missing_imports = True + +[mypy-pkg_resources.*] +ignore_missing_imports = True + +[mypy-pytest.*] +ignore_missing_imports = True diff --git a/swh/__init__.py b/swh/__init__.py index 69e3be5..f14e196 100644 --- a/swh/__init__.py +++ b/swh/__init__.py @@ -1 +1,4 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) +from pkgutil import extend_path +from typing import Iterable + +__path__ = extend_path(__path__, __name__) # type: Iterable[str] diff --git a/swh/loader/__init__.py b/swh/loader/__init__.py index 69e3be5..f14e196 100644 --- a/swh/loader/__init__.py +++ b/swh/loader/__init__.py @@ -1 +1,4 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) +from pkgutil import extend_path +from typing import Iterable + +__path__ = extend_path(__path__, __name__) # type: Iterable[str] diff --git a/swh/loader/npm/py.typed b/swh/loader/npm/py.typed new file mode 100644 index 0000000..1242d43 --- /dev/null +++ b/swh/loader/npm/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. diff --git a/tox.ini b/tox.ini index 753ff1c..2461ca6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=flake8,py3 +envlist=flake8,mypy,py3 [testenv:py3] deps = @@ -16,3 +16,11 @@ deps = flake8 commands = {envpython} -m flake8 + +[testenv:mypy] +skip_install = true +deps = + .[testing] + mypy +commands = + mypy swh -- GitLab From 2d3057edbe75cedf891ae799c4b8d60425d897ee Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli <zack@upsilon.cc> Date: Fri, 1 Nov 2019 15:23:15 +0100 Subject: [PATCH 2/2] MANIFEST.in: ship py.typed --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 0d0a1dd..7b48204 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,4 @@ include requirements-test.txt include version.txt include README.md recursive-include swh/loader/npm/tests/resources * +recursive-include swh py.typed -- GitLab