Skip to content

Commit 03ee5d1

Browse files
committed
Bring mypy into the tox config
1 parent a893c30 commit 03ee5d1

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ tmp.py
33
htmlcov/
44
.coverage.*
55
*.py[cod]
6+
.mypy_cache
67

78
# emacs
89
*~

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
zip_safe=False,
3131
license=__license__,
3232
platforms='any',
33-
install_requires=['idna>=2.5'],
33+
install_requires=[
34+
'idna>=2.5',
35+
'typing ; python_version<"3.5"',
36+
],
3437
classifiers=[
3538
'Topic :: Utilities',
3639
'Intended Audience :: Developers',

tox.ini

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ basepython =
3131
deps =
3232
test: coverage==4.5.4
3333
test: idna==2.8
34+
test: typing==3.7.4.1
3435
test: {py26,py27,py34}: pytest==4.6.6
3536
test: {py35,py36,py37,py38}: pytest==5.2.1
3637
test: pytest-cov==2.8.1
@@ -122,6 +123,74 @@ ignore =
122123
application-import-names = deploy
123124

124125

126+
##
127+
# Mypy static type checking
128+
##
129+
130+
[testenv:mypy]
131+
132+
description = run Mypy (static type checker)
133+
134+
basepython = python3.7
135+
136+
skip_install = True
137+
138+
139+
deps =
140+
mypy==0.730
141+
142+
143+
commands =
144+
mypy \
145+
--config-file="{toxinidir}/tox.ini" \
146+
--cache-dir="{toxworkdir}/mypy_cache" \
147+
{tty:--pretty:} \
148+
{posargs:src}
149+
150+
151+
[mypy]
152+
153+
# Global settings
154+
155+
no_implicit_optional = True
156+
show_column_numbers = True
157+
show_error_codes = True
158+
strict_optional = True
159+
warn_no_return = True
160+
warn_redundant_casts = True
161+
warn_return_any = True
162+
warn_unused_ignores = True
163+
warn_unreachable = True
164+
165+
# Enable these over time
166+
check_untyped_defs = False
167+
disallow_incomplete_defs = False
168+
disallow_untyped_defs = False
169+
170+
# Disable checks until effected files fully adopt mypy
171+
172+
[mypy-hyperlink._url]
173+
allow_untyped_defs = True
174+
175+
[mypy-hyperlink.test.common]
176+
allow_untyped_defs = True
177+
178+
[mypy-hyperlink.test.test_common]
179+
allow_untyped_defs = True
180+
181+
[mypy-hyperlink.test.test_decoded_url]
182+
allow_untyped_defs = True
183+
184+
[mypy-hyperlink.test.test_scheme_registration]
185+
allow_untyped_defs = True
186+
187+
[mypy-hyperlink.test.test_url]
188+
allow_untyped_defs = True
189+
190+
[mypy-idna]
191+
ignore_missing_imports = True
192+
193+
125194
##
126195
# Coverage report
127196
##

0 commit comments

Comments
 (0)