From 829d261055638d4f25302866f247520981ad434c Mon Sep 17 00:00:00 2001 From: Abram Booth Date: Mon, 25 Mar 2024 13:18:12 -0400 Subject: [PATCH] add mypy to pre-commit --- .pre-commit-config.yaml | 4 +++ mypy.ini | 52 +++++++++++++++++++++++++++++++ requirements/dev-requirements.txt | 3 ++ 3 files changed, 59 insertions(+) create mode 100644 mypy.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 686a9c8c..4a407ab1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000..3c47cc7c --- /dev/null +++ b/mypy.ini @@ -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 diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index 5605da94..35f90bf7 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -10,3 +10,6 @@ flake8 black isort pre-commit + +# Type checking +mypy