Mypy type checking (#119)

* Update Makefile

* Update changelog

* gitignore mypy cache

* mypy config

* Add color to mypy output

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
This commit is contained in:
Quentin Gallouédec 2022-11-28 23:00:31 +01:00 committed by GitHub
parent 703fd2dd68
commit 3d28d1e5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 1 deletions

View File

@ -11,6 +11,9 @@ on:
jobs:
build:
env:
TERM: xterm-256color
FORCE_COLOR: 1
# Skip CI if [ci skip] in the commit message
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ _build/
*.npz
*.pth
.pytype/
.mypy_cache
git_rewrite_commit_history.sh
# Setuptools distribution and build folders.

View File

@ -4,9 +4,14 @@ LINT_PATHS=sb3_contrib/ tests/ setup.py
pytest:
./scripts/run_tests.sh
type:
pytype:
pytype -j auto
mypy:
mypy ${LINT_PATHS}
type: pytype mypy
lint:
# stop the build if there are Python syntax errors or undefined names
# see https://lintlyci.github.io/Flake8Rules/

View File

@ -14,6 +14,7 @@ Breaking Changes:
New Features:
^^^^^^^^^^^^^
- Introduced mypy type checking
Bug Fixes:
^^^^^^^^^^

View File

@ -19,6 +19,33 @@ markers =
[pytype]
inputs = sb3_contrib
[mypy]
ignore_missing_imports = True
follow_imports = silent
show_error_codes = True
exclude = (?x)(
sb3_contrib/ppo_recurrent/ppo_recurrent.py$
| sb3_contrib/ars/ars.py$
| sb3_contrib/ars/policies.py$
| sb3_contrib/qrdqn/qrdqn.py$
| sb3_contrib/qrdqn/policies.py$
| sb3_contrib/common/recurrent/type_aliases.py$
| sb3_contrib/common/recurrent/policies.py$
| sb3_contrib/common/recurrent/buffers.py$
| sb3_contrib/common/utils.py$
| sb3_contrib/common/maskable/distributions.py$
| sb3_contrib/common/maskable/callbacks.py$
| sb3_contrib/common/maskable/policies.py$
| sb3_contrib/common/maskable/buffers.py$
| sb3_contrib/common/envs/invalid_actions_env.py$
| sb3_contrib/common/vec_env/async_eval.py$
| sb3_contrib/tqc/tqc.py$
| sb3_contrib/tqc/policies.py$
| sb3_contrib/trpo/trpo.py$
| sb3_contrib/ppo_mask/ppo_mask.py$
| tests/test_train_eval_mode.py$
)
[flake8]
# line breaks before and after binary operators
ignore = W503,W504,E203,E231