summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kurnikov <maxim.kurnikov@gmail.com>2019-02-25 16:04:21 +0300
committerMaxim Kurnikov <maxim.kurnikov@gmail.com>2019-02-25 16:14:00 +0300
commit7a98fd09b1779ea6f55abee27b492d1ff75337de (patch)
tree1750e5b21155f33a628fc38607f54dbcae953250
parent7845cc5466f3dc0de17a4444593bf78c204dae51 (diff)
downloadisort-7a98fd09b1779ea6f55abee27b492d1ff75337de.tar.gz
add mypy to CI
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml2
-rw-r--r--isort/main.py3
-rw-r--r--isort/settings.py10
-rw-r--r--mypy-requirements.txt2
-rw-r--r--setup.cfg5
-rw-r--r--tox.ini8
7 files changed, 27 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 10fe6e96..11a657c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,3 +67,6 @@ pip-selfcheck.json
# Python3 Venv Files
venv/
pyvenv.cfg
+
+# mypy
+.mypy_cache \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index e1205586..9c711d42 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,8 @@ matrix:
env: TOXENV=isort-check
- python: 3.7
env: TOXENV=lint
+ - python: 3.7
+ env: TOXENV=mypy
- python: 3.4
env: TOXENV=py34
- python: 3.5
diff --git a/isort/main.py b/isort/main.py
index a24864fa..e4bc9107 100644
--- a/isort/main.py
+++ b/isort/main.py
@@ -23,6 +23,7 @@ import glob
import os
import re
import sys
+from typing import Any, List # noqa: F401
import setuptools
@@ -123,7 +124,7 @@ class ISortCommand(setuptools.Command):
"""
description = "Run isort on modules registered in setuptools"
- user_options = []
+ user_options = [] # type: List[Any]
def initialize_options(self):
default_settings = default.copy()
diff --git a/isort/settings.py b/isort/settings.py
index 3603a2f2..5a21fa30 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -38,7 +38,7 @@ from .utils import difference, union
try:
import toml
except ImportError:
- toml = False
+ toml = None
try:
import appdirs
@@ -54,9 +54,9 @@ safety_exclude_re = re.compile(
r"/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|lib/python[0-9].[0-9]+)/"
)
-WrapModes = ('GRID', 'VERTICAL', 'HANGING_INDENT', 'VERTICAL_HANGING_INDENT', 'VERTICAL_GRID', 'VERTICAL_GRID_GROUPED',
- 'VERTICAL_GRID_GROUPED_NO_COMMA', 'NOQA')
-WrapModes = namedtuple('WrapModes', WrapModes)(*range(len(WrapModes)))
+_wrap_mode_strings = ('GRID', 'VERTICAL', 'HANGING_INDENT', 'VERTICAL_HANGING_INDENT', 'VERTICAL_GRID', 'VERTICAL_GRID_GROUPED',
+ 'VERTICAL_GRID_GROUPED_NO_COMMA', 'NOQA')
+WrapModes = namedtuple('WrapModes', _wrap_mode_strings)(*range(len(_wrap_mode_strings)))
# Note that none of these lists must be complete as they are simply fallbacks for when included auto-detection fails.
default = {'force_to_top': [],
@@ -115,7 +115,7 @@ default = {'force_to_top': [],
'zipimport', 'zlib'],
'known_third_party': ['google.appengine.api'],
'known_first_party': [],
- 'multi_line_output': WrapModes.GRID,
+ 'multi_line_output': WrapModes.GRID, # type: ignore
'forced_separate': [],
'indent': ' ' * 4,
'comment_prefix': ' #',
diff --git a/mypy-requirements.txt b/mypy-requirements.txt
new file mode 100644
index 00000000..8006c4ad
--- /dev/null
+++ b/mypy-requirements.txt
@@ -0,0 +1,2 @@
+mypy==0.670
+typing==3.6.6 \ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
index c39295eb..fcf1fbad 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -10,3 +10,8 @@ ignore =
[metadata]
license_file = LICENSE
+
+[mypy]
+follow_imports = silent
+ignore_missing_imports = True
+strict_optional = False \ No newline at end of file
diff --git a/tox.ini b/tox.ini
index cb36b189..3e2cc62d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,6 +3,7 @@ minversion = 2.4
envlist =
isort-check,
lint,
+ mypy,
py{34,35,36,37,py3}
[testenv]
@@ -22,3 +23,10 @@ commands = python setup.py isort
deps = flake8==3.5.0
commands = flake8
skip_install = True
+
+[testenv:mypy]
+basepython = python3
+deps = -r{toxinidir}/mypy-requirements.txt
+commands =
+ mypy .
+skip_install = True