From 003783ce058aebe486474df16aeca9192562613c Mon Sep 17 00:00:00 2001 From: kenjihiraoka Date: Tue, 15 Sep 2020 22:13:54 -0300 Subject: [PATCH 1/3] add mypy file --- mypy.ini | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mypy.ini diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000000..5ef86a5e30fe --- /dev/null +++ b/mypy.ini @@ -0,0 +1,32 @@ +[mypy] +files = ignite +pretty = True +show_error_codes = True + +[mypy-ignite.base.*] + +ignore_errors = True + +[mypy-ignite.contrib.*] + +ignore_errors = True + +[mypy-ignite.handlers.*] + +ignore_errors = True + +[mypy-ignite.engine.*] + +ignore_errors = True + +[mypy-ignite.metrics.*] + +ignore_errors = True + +[mypy-ignite.distributed.*] + +ignore_errors = True + +[mypy-ignite.utils.*] + +ignore_errors = True From 349fb88d1d5bbd8ec8224d1bbe783f34bdb22a70 Mon Sep 17 00:00:00 2001 From: kenjihiraoka Date: Tue, 15 Sep 2020 22:14:15 -0300 Subject: [PATCH 2/3] add mypy at CI step --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d49b074e36a1..e148849bbb98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,11 +51,12 @@ jobs: - stage: Lint check python: "3.7" before_install: # Nothing to do - install: pip install flake8 "black==19.10b0" "isort==4.3.21" + install: pip install flake8 "black==19.10b0" "isort==4.3.21" "mypy==0.782" script: - flake8 . - black --check . - isort -rc -c . + - mypy --config-file mypy.ini after_success: # Nothing to do # GitHub Pages Deployment: https://docs.travis-ci.com/user/deployment/pages/ From 4359fe112dd27cc061097b6b23bb1e19e9d329ef Mon Sep 17 00:00:00 2001 From: kenjihiraoka Date: Tue, 15 Sep 2020 22:14:34 -0300 Subject: [PATCH 3/3] add mypy step at Contributing.md --- CONTRIBUTING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84f312a969d4..4f2006061be5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ git clone https://github.com/pytorch/ignite.git cd ignite python setup.py develop pip install -r requirements-dev.txt -pip install flake8 "black==19.10b0" "isort==4.3.21" +pip install flake8 "black==19.10b0" "isort==4.3.21" "mypy==0.782" ``` ### Code development @@ -126,6 +126,14 @@ CI_PYTHON_VERSION= sh tests/run_cpu_tests.sh # CI_PYTHON_VERSION=3.7 sh tests/run_cpu_tests.sh ``` +#### Run Mypy checks: +To run mypy to check the optional static type: +```bash +mypy --config-file mypy.ini +``` + +To change any config for specif folder, please see the file mypy.ini + #### Send a PR If everything is OK, please send a Pull Request to https://github.com/pytorch/ignite