Skip to content

Commit 829d261

Browse files
committed
add mypy to pre-commit
1 parent fb67186 commit 829d261

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ repos:
1111
rev: 5.12.0
1212
hooks:
1313
- id: isort
14+
- repo: https://github.com/pre-commit/mirrors-mypy
15+
rev: '9db9854e3041219b1eb619872a2dfaf58adfb20b' # v1.9.0
16+
hooks:
17+
- id: mypy

mypy.ini

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[mypy]
2+
# start with an ideal: enable strict type-checking, then loosen in module-specific config
3+
# see https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
4+
strict = True
5+
## BEGIN aspects of `strict` that could be loosened:
6+
# disallow_subclassing_any = False
7+
# warn_unused_configs = False
8+
# warn_redundant_casts = False
9+
# warn_unused_ignores = False
10+
# strict_equality = False
11+
# strict_concatenate = False
12+
# check_untyped_defs = False
13+
# disallow_untyped_decorators = False
14+
# disallow_any_generics = False
15+
# disallow_untyped_calls = False
16+
# disallow_incomplete_defs = False
17+
# disallow_untyped_defs = False
18+
# no_implicit_reexport = False
19+
# warn_return_any = False
20+
## END aspects of `strict`
21+
22+
# prefer types that can be understood by reading code in only one place
23+
local_partial_types = True
24+
# avoid easily-avoidable dead code
25+
warn_unreachable = True
26+
27+
###
28+
# module-specific config
29+
30+
[mypy-addon_toolkit.*]
31+
## loosen strict:
32+
disallow_any_generics = False
33+
disallow_untyped_calls = False
34+
disallow_incomplete_defs = False
35+
disallow_untyped_defs = False
36+
37+
[mypy-addon_service.*,app.*,manage]
38+
# got untyped dependencies -- this is fine
39+
ignore_missing_imports = True
40+
disable_error_code = import-untyped,import-not-found
41+
## loosen strict:
42+
disallow_subclassing_any = False
43+
disallow_untyped_decorators = False
44+
disallow_any_generics = False
45+
disallow_untyped_calls = False
46+
disallow_incomplete_defs = False
47+
disallow_untyped_defs = False
48+
warn_return_any = False
49+
50+
[mypy-addon_service.migrations.*]
51+
strict = False
52+
disable_error_code = var-annotated

requirements/dev-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ flake8
1010
black
1111
isort
1212
pre-commit
13+
14+
# Type checking
15+
mypy

0 commit comments

Comments
 (0)