summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2016-11-07 13:15:18 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2016-11-16 12:05:44 +0900
commitdb732ac0b839a028a868a180550bb4f55d6e9b4b (patch)
treef6b13677407a36b0a12462ac15c1b22dd002a504
parentde3e8580c4a2cfaca2c07c794d01c1e8eb0dd384 (diff)
downloadsphinx-git-db732ac0b839a028a868a180550bb4f55d6e9b4b.tar.gz
Prepare to type-check using mypy
-rw-r--r--.gitignore1
-rw-r--r--Makefile7
-rw-r--r--mypy.ini6
-rw-r--r--setup.py1
-rw-r--r--test-reqs.txt1
-rw-r--r--tox.ini4
-rwxr-xr-xutils/check_sources.py3
7 files changed, 21 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index be28908ec..86a8baf9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.swp
.dir-locals.el
+.mypy_cache/
.ropeproject/
TAGS
.tags
diff --git a/Makefile b/Makefile
index 01e3a7837..86226f3b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
PYTHON ?= python
-.PHONY: all style-check clean clean-pyc clean-patchfiles clean-backupfiles \
+.PHONY: all style-check type-check clean clean-pyc clean-patchfiles clean-backupfiles \
clean-generated pylint reindent test covertest build
DONT_CHECK = -i build -i dist -i sphinx/style/jquery.js \
@@ -30,11 +30,14 @@ DONT_CHECK = -i build -i dist -i sphinx/style/jquery.js \
-i sphinx/search/tr.py \
-i .tox
-all: clean-pyc clean-backupfiles style-check test
+all: clean-pyc clean-backupfiles style-check type-check test
style-check:
@$(PYTHON) utils/check_sources.py $(DONT_CHECK) .
+type-check:
+ mypy sphinx/
+
clean: clean-pyc clean-pycache clean-patchfiles clean-backupfiles clean-generated clean-testfiles clean-buildfiles
clean-pyc:
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
index 000000000..17ded7ab8
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,6 @@
+[mypy]
+python_version = 2.7
+silent_imports = True
+fast_parser = True
+incremental = True
+check_untyped_defs = True
diff --git a/setup.py b/setup.py
index 37c10b345..e23c4fb59 100644
--- a/setup.py
+++ b/setup.py
@@ -51,6 +51,7 @@ requires = [
'alabaster>=0.7,<0.8',
'imagesize',
'requests',
+ 'typing',
]
extras_require = {
# Environment Marker works for wheel 0.24 or later
diff --git a/test-reqs.txt b/test-reqs.txt
index b53adbfe5..13cb3a9ff 100644
--- a/test-reqs.txt
+++ b/test-reqs.txt
@@ -16,3 +16,4 @@ imagesize
requests
html5lib
enum34
+typing
diff --git a/tox.ini b/tox.ini
index ca3cac99b..957fbcc38 100644
--- a/tox.ini
+++ b/tox.ini
@@ -47,6 +47,10 @@ deps=
{[testenv]deps}
[testenv:py35]
+deps=
+ mypy-lang
+ typed_ast
+ {[testenv]deps}
commands=
{envpython} tests/run.py -m '^[tT]est' {posargs}
sphinx-build -q -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
diff --git a/utils/check_sources.py b/utils/check_sources.py
index 18d444057..d4a5ab491 100755
--- a/utils/check_sources.py
+++ b/utils/check_sources.py
@@ -46,6 +46,7 @@ copyright_2_re = re.compile(r'^ %s(, %s)*[,.]$' %
(name_mail_re, name_mail_re))
not_ix_re = re.compile(r'\bnot\s+\S+?\s+i[sn]\s\S+')
is_const_re = re.compile(r'if.*?==\s+(None|False|True)\b')
+noqa_re = re.compile(r'#\s+NOQA\s*$', re.I)
misspellings = ["developement", "adress", # ALLOW-MISSPELLING
"verificate", "informations"] # ALLOW-MISSPELLING
@@ -81,6 +82,8 @@ def check_syntax(fn, lines):
@checker('.py')
def check_style(fn, lines):
for lno, line in enumerate(lines):
+ if noqa_re.search(line):
+ continue
if len(line.rstrip('\n')) > 95:
yield lno+1, "line too long"
if line.strip().startswith('#'):