From f495b1d0796a83689607eec9616a004312f67e02 Mon Sep 17 00:00:00 2001 From: irl Date: Sun, 15 May 2022 16:56:31 +0000 Subject: [PATCH] Add mypy to GitLab CI --- .gitlab-ci.yml | 10 +++++++++- mypy.ini | 27 +++++++++++++++++++++++++++ requirements-types.txt | 4 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 mypy.ini create mode 100644 requirements-types.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98719ba..a44ba6d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,14 @@ image: python:3.8-bullseye -test: +test:mypy: + script: + - cp config.yaml.example config.yaml + - apt update && apt install build-essential + - pip install -r requirements.txt --quiet + - pip install -r requirements-types.txt --quiet + - mypy app + +test:docs: stage: test script: - cp config.yaml.example config.yaml diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..10e0f1a --- /dev/null +++ b/mypy.ini @@ -0,0 +1,27 @@ +[mypy] +; Ensure full coverage +disallow_untyped_calls = True +disallow_untyped_defs = True +disallow_incomplete_defs = True +disallow_untyped_decorators = True +check_untyped_defs = True + +; Restrict dynamic typing +disallow_any_generics = True +disallow_subclassing_any = True +warn_return_any = True + +; Know exactly what you're doing +warn_redundant_casts = True +warn_unused_ignores = True +warn_unused_configs = True +warn_unreachable = True +show_error_codes = True + +; Explicit is better than implicit +no_implicit_optional = True + +; Some libraries don't have hints yet +ignore_missing_imports = True +follow_imports = silent + diff --git a/requirements-types.txt b/requirements-types.txt new file mode 100644 index 0000000..2be97fb --- /dev/null +++ b/requirements-types.txt @@ -0,0 +1,4 @@ +mypy +types-requests +types-PyYAML +types-python-dateutil