diff --git a/requirements/dev.txt b/requirements/dev.txt index 6387294..fa91028 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -5,3 +5,4 @@ pep8-naming flake8-print tox pre-commit +mypy diff --git a/requirements/mypy.txt b/requirements/mypy.txt new file mode 100644 index 0000000..2f2229c --- /dev/null +++ b/requirements/mypy.txt @@ -0,0 +1,5 @@ +mypy +# mypy has the pydantic plugin enabled +pydantic>=2.0.0,<3.0 +types-requests +deprecation>=2.0,<3.0 diff --git a/tox.ini b/tox.ini index 0436a1b..1b95d5f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38,39,310,311,312},lint +envlist = py{38,39,310,311,312},lint,mypy,mypy-samples-{image,json} skipsdist = True [testenv] @@ -30,3 +30,21 @@ commands = black --check . isort -c cloudevents samples flake8 cloudevents samples --ignore W503,E731 --extend-ignore E203 --max-line-length 88 + +[testenv:mypy] +basepython = python3.11 +deps = + -r{toxinidir}/requirements/mypy.txt + # mypy needs test dependencies to check test modules + -r{toxinidir}/requirements/test.txt +commands = mypy cloudevents + +[testenv:mypy-samples-{image,json}] +basepython = python3.11 +setenv = + mypy-samples-image: SAMPLE_DIR={toxinidir}/samples/http-image-cloudevents + mypy-samples-json: SAMPLE_DIR={toxinidir}/samples/http-json-cloudevents +deps = + -r{toxinidir}/requirements/mypy.txt + -r{env:SAMPLE_DIR}/requirements.txt +commands = mypy {env:SAMPLE_DIR}