Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static type checker mypy to the tests and pre-commit hooks #433

Merged
merged 8 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 --version
Borda marked this conversation as resolved.
Show resolved Hide resolved
- 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
Comment on lines +65 to +69
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following PyTorch's mypy configuration file, I added the tests as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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