From c09e21ae4bf63baa5723f73260581a50f317cb46 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 22:19:24 +0100 Subject: [PATCH] Configure mypy No fixes yet, this just gets the config in place. Note: I'm assuming that we'll pick up a change to parso such that it exposes its type stubs here. Otherwise we'll want to tweak the imports config to ignore those errors. --- .travis.yml | 1 + setup.cfg | 32 ++++++++++++++++++++++++++++++++ setup.py | 1 + 3 files changed, 34 insertions(+) diff --git a/.travis.yml b/.travis.yml index 89102f4a..e3b32895 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ matrix: script: # Ignore F401, which are unused imports. flake8 is a primitive tool and is sometimes wrong. - 'flake8 --extend-ignore F401 jedi setup.py' + - 'mypy jedi' install: - sudo apt-get -y install python3-venv - pip install .[testing] diff --git a/setup.cfg b/setup.cfg index 6929ce30..54fd65db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,3 +19,35 @@ exclude = jedi/third_party/* .tox/* [pycodestyle] max-line-length = 100 + + +[mypy] +# Ensure generics are explicit about what they are (e.g: `List[str]` rather than +# just `List`) +disallow_any_generics = True + +disallow_subclassing_any = True + +# Ensure that optional types are explicit +no_implicit_optional = True +strict_optional = True + +# Avoid creating future gotchas emerging from bad typing +warn_redundant_casts = True +warn_unused_ignores = True +warn_return_any = True +warn_unused_configs = True + +warn_unreachable = True + +# Require values to be explicitly re-exported; this makes things easier for +# Flake8 too and avoids accidentally importing thing from the "wrong" place +# (which helps avoid circular imports) +implicit_reexport = False + +strict_equality = True + +[mypy-jedi.debug] +# jedi.debug is configured by setting module-level values, which mypy doesn't +# know about. +warn_unreachable = False diff --git a/setup.py b/setup.py index bf9be8c2..b4f9da2a 100755 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ setup(name='jedi', ], 'qa': [ 'flake8==3.8.3', + 'mypy==0.782', ], }, package_data={'jedi': ['*.pyi', 'third_party/typeshed/LICENSE',