Skip to content

Commit

Permalink
Add static type checker mypy to the tests and pre-commit hooks (Light…
Browse files Browse the repository at this point in the history
…ning-Universe#433)

* Add mypy check to GitHub Actions

* Run mypy on pl_bolts only

* Add mypy check to pre-commit

* Add an empty line at the end of files

* Update mypy config

* Update mypy config

* Update mypy config

* show

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
  • Loading branch information
2 people authored and Christoph Clement committed Dec 16, 2020
1 parent 0f41495 commit 4795612
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ jobs:
- name: isort
run: |
isort . --check --diff
typing-check-mypy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install mypy
run: |
pip install mypy
pip list
- name: mypy
run: |
mypy
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ repos:
- repo: https://github.com/pycqa/isort
rev: 5.5.2
hooks:
- id: isort
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
hooks:
- id: mypy
62 changes: 62 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,65 @@ license_file = LICENSE
description-file = README.md
# long_description = file:README.md
# long_description_content_type = text/markdown

[mypy]
# Typing tests is low priority, but enabling type checking on the
# untyped test functions (using `--check-untyped-defs`) is still
# high-value because it helps test the typing.
files = pl_bolts, tests
disallow_untyped_defs = True
ignore_missing_imports = True

[mypy-pl_bolts.*]
ignore_errors = True

[mypy-pl_bolts.callbacks.*]
ignore_errors = True

[mypy-pl_bolts.datamodules.*]
ignore_errors = True

[mypy-pl_bolts.datasets.*]
ignore_errors = True

[mypy-pl_bolts.losses.*]
ignore_errors = True

[mypy-pl_bolts.metrics.*]
ignore_errors = True

[mypy-pl_bolts.models.*]
ignore_errors = True

[mypy-pl_bolts.models.autoencoders.*]
ignore_errors = True

[mypy-pl_bolts.models.detection.*]
ignore_errors = True

[mypy-pl_bolts.models.gans.*]
ignore_errors = True

[mypy-pl_bolts.models.regression.*]
ignore_errors = True

[mypy-pl_bolts.models.rl.*]
ignore_errors = True

[mypy-pl_bolts.models.self_supervised.*]
ignore_errors = True

[mypy-pl_bolts.models.vision.*]
ignore_errors = True

[mypy-pl_bolts.optimizers.*]
ignore_errors = True

[mypy-pl_bolts.transforms.*]
ignore_errors = True

[mypy-pl_bolts.utils.*]
ignore_errors = True

[mypy-tests.*]
ignore_errors = True

0 comments on commit 4795612

Please sign in to comment.