Skip to content

Commit

Permalink
add mypy to pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Apr 10, 2024
1 parent fb67186 commit 829d261
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: '9db9854e3041219b1eb619872a2dfaf58adfb20b' # v1.9.0
hooks:
- id: mypy
52 changes: 52 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[mypy]
# start with an ideal: enable strict type-checking, then loosen in module-specific config
# see https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
strict = True
## BEGIN aspects of `strict` that could be loosened:
# disallow_subclassing_any = False
# warn_unused_configs = False
# warn_redundant_casts = False
# warn_unused_ignores = False
# strict_equality = False
# strict_concatenate = False
# check_untyped_defs = False
# disallow_untyped_decorators = False
# disallow_any_generics = False
# disallow_untyped_calls = False
# disallow_incomplete_defs = False
# disallow_untyped_defs = False
# no_implicit_reexport = False
# warn_return_any = False
## END aspects of `strict`

# prefer types that can be understood by reading code in only one place
local_partial_types = True
# avoid easily-avoidable dead code
warn_unreachable = True

###
# module-specific config

[mypy-addon_toolkit.*]
## loosen strict:
disallow_any_generics = False
disallow_untyped_calls = False
disallow_incomplete_defs = False
disallow_untyped_defs = False

[mypy-addon_service.*,app.*,manage]
# got untyped dependencies -- this is fine
ignore_missing_imports = True
disable_error_code = import-untyped,import-not-found
## loosen strict:
disallow_subclassing_any = False
disallow_untyped_decorators = False
disallow_any_generics = False
disallow_untyped_calls = False
disallow_incomplete_defs = False
disallow_untyped_defs = False
warn_return_any = False

[mypy-addon_service.migrations.*]
strict = False
disable_error_code = var-annotated
3 changes: 3 additions & 0 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ flake8
black
isort
pre-commit

# Type checking
mypy

0 comments on commit 829d261

Please sign in to comment.