summaryrefslogtreecommitdiff
path: root/tox.ini
diff options
context:
space:
mode:
authorStephen Rosen <sirosen@globus.org>2021-12-10 23:30:32 +0000
committerStephen Rosen <sirosen@globus.org>2022-01-05 22:30:00 +0000
commit5a2f8ee5a4b428582d7224b79da17277648820a2 (patch)
treed129d8e56402e7b6b3ae8ed39cf2c6099d9045ff /tox.ini
parentfc0990a365d162a3e90b3d5296788146331f69ee (diff)
downloadjsonschema-5a2f8ee5a4b428582d7224b79da17277648820a2.tar.gz
Setup mypy in `tox -e typing` and get it to pass
This is the smallest possible change to get mypy passing on the jsonschema codebase. The goal of this configuration is to enforce type annotations anywhere that they appear. That is, if a method is added to the codebase, def foo(x: int) -> str: return str(x) then usages of `foo` will by type checked. If no annotations are added, `mypy` will not type check functions. For the most part, this keeps the impact low. The one exceptional case is the use of `pyrsistent.pmap` as an argument to `attr.ib(converter=...)`. Unfortunately, it causes `mypy` to incorrectly deduce the type of the init parameter created by attrs. We need to "explain the type of init" to mypy by creating a callable with a concrete type to act as the converter. The callable in question simply wraps `pmap` with a cast and presents the desired type information to mypy.
Diffstat (limited to 'tox.ini')
-rw-r--r--tox.ini10
1 files changed, 10 insertions, 0 deletions
diff --git a/tox.ini b/tox.ini
index eea61c6..ced13cc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,6 +5,7 @@ envlist =
safety
secrets
style
+ typing
docs-{html,doctest,linkcheck,spelling,style}
skipsdist = True
@@ -89,6 +90,15 @@ deps =
commands =
{envpython} -m flake8 {posargs} {toxinidir}/jsonschema {toxinidir}/docs
+[testenv:typing]
+skip_install = true
+deps =
+ mypy
+ pyrsistent
+ types-attrs
+ types-requests
+commands = {envpython} -m mypy --config {toxinidir}/setup.cfg {posargs} {toxinidir}/jsonschema
+
[testenv:docs-dirhtml]
commands = {envpython} -m sphinx -b dirhtml {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -q -T -W}
deps =