mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Prepare to type-check using mypy
This commit is contained in:
parent
de3e8580c4
commit
db732ac0b8
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@
|
||||
*.swp
|
||||
|
||||
.dir-locals.el
|
||||
.mypy_cache/
|
||||
.ropeproject/
|
||||
TAGS
|
||||
.tags
|
||||
|
7
Makefile
7
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:
|
||||
|
6
mypy.ini
Normal file
6
mypy.ini
Normal file
@ -0,0 +1,6 @@
|
||||
[mypy]
|
||||
python_version = 2.7
|
||||
silent_imports = True
|
||||
fast_parser = True
|
||||
incremental = True
|
||||
check_untyped_defs = True
|
1
setup.py
1
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
|
||||
|
@ -16,3 +16,4 @@ imagesize
|
||||
requests
|
||||
html5lib
|
||||
enum34
|
||||
typing
|
||||
|
4
tox.ini
4
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
|
||||
|
@ -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('#'):
|
||||
|
Loading…
Reference in New Issue
Block a user