build: run mypy via tox

Tox now runs mypy on cloudevents itself, and the samples.

Signed-off-by: Hal Blackburn <hwtb2@cam.ac.uk>
This commit is contained in:
Hal Blackburn 2025-03-25 06:14:47 +00:00
parent b70ef0ad6b
commit 66aa64b3af
No known key found for this signature in database
3 changed files with 25 additions and 1 deletions

View File

@ -5,3 +5,4 @@ pep8-naming
flake8-print
tox
pre-commit
mypy

5
requirements/mypy.txt Normal file
View File

@ -0,0 +1,5 @@
mypy
# mypy has the pydantic plugin enabled
pydantic>=2.0.0,<3.0
types-requests
deprecation>=2.0,<3.0

20
tox.ini
View File

@ -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}