From 89971d09bd1bd1d491aa7fde8f2e45035a1f32c9 Mon Sep 17 00:00:00 2001 From: goerlibe Date: Mon, 11 Sep 2023 16:36:29 +0200 Subject: [PATCH] feat: common mypy configuration file --- .github/workflows/ci.yml | 8 ++++---- .pre-commit-config.yaml | 4 +++- mypy.ini | 43 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 mypy.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08e935012..54ce27652 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,16 +42,16 @@ jobs: run: pip install -r requirements.txt - name: "Run MyPy Type Checker - DiscoPoP Explorer" - run: python -m mypy -p discopop_explorer + run: python -m mypy --config-file=mypy.ini -p discopop_explorer - name: "Run MyPy Type Checker - DiscoPoP Library" - run: python -m mypy -p discopop_library + run: python -m mypy --config-file=mypy.ini -p discopop_library - name: "Run MyPy Type Checker - DiscoPoP Profiler" - run: python -m mypy -p discopop_profiler + run: python -m mypy --config-file=mypy.ini -p discopop_profiler - name: "Run MyPy Type Checker - DiscoPoP Wizard" - run: python -m mypy -p discopop_wizard + run: python -m mypy --config-file=mypy.ini -p discopop_wizard - name: "Check formatting of DiscoPoP Explorer" run: python -m black -l 100 --check discopop_explorer diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3a0e9f50f..4d5b797e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,8 +30,10 @@ repos: rev: 'v1.5.1' # Use the sha / tag you want to point at hooks: - id: mypy # run mypy - #args: [--strict, --ignore-missing-imports] + args: [--config-file=mypy.ini, --ignore-missing-imports] #additional_dependencies: [dep==version.version.version, ...] + # NOTE: pre-commit runs mypy in a virtualenv, so dependencies are not installed unless explicitly listed here + # TODO: how do we manage the dependencies? # Using this mirror lets us use mypyc-compiled black, which is about 2x faster # more info: https://github.com/psf/black/blob/main/docs/integrations/source_version_control.md diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000..2287dd58d --- /dev/null +++ b/mypy.ini @@ -0,0 +1,43 @@ +# This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de) +# +# Copyright (c) 2020, Technische Universitaet Darmstadt, Germany +# +# This software may be modified and distributed under the terms of +# the 3-Clause BSD License. See the LICENSE file in the package base +# directory for details. + +# this file specifies common mypy options for the DiscoPoP project +# call mypy with `--config-file=mypy.ini` +# check https://mypy.readthedocs.io/en/stable/config_file.html for more details + +[mypy] +# select files to check +files = discopop_explorer, discopop_library, discopop_profiler, discopop_wizard + +# helps to catch typos in this file +warn_unused_configs = True +# the following options should be enabled one by one, then we will switch to `strict` type checking: + +#warn_redundant_casts = True + +#disallow-any-generics +#disallow-subclassing-any +#disallow-untyped-calls +#disallow-untyped-defs +#disallow-incomplete-defs +#check-untyped-defs +#disallow-untyped-decorators +#warn-unused-ignores +#warn-return-any +#no-implicit-reexport +#strict-equality +#extra-checks + +# while we transition to --strict, we will allow project-specific settings, later everything should be strictly checked +[mypy-discopop_explorer.*] + +[mypy-discopop_library.*] + +[mypy-discopop_profiler.*] + +[mypy-discopop_wizard.*]