From 92ae49a223596da07c460a3a8fcb695a40ee9ccc Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sat, 19 Aug 2023 17:53:35 -0700 Subject: [PATCH] chore: add intial `mypy` testing in preparation for type-hints Related to #463 --- pyproject.toml | 64 ++++++++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 + tox.ini | 7 ++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cf7dc5e3..a0f54775 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,67 @@ profile = "black" multi_line_output = 3 order_by_type = false + +[tool.mypy] +files = "." +exclude = [ + "doc/.*", + "examples/.*", + "tests/.*", +] + +show_error_codes = true + +# 'strict = true' is equivalent to: +# --check-untyped-defs +# --disallow-any-generics +# --disallow-incomplete-defs +# --disallow-subclassing-any +# --disallow-untyped-calls +# --disallow-untyped-decorators +# --disallow-untyped-defs +# --extra-checks +# --no-implicit-reexport +# --strict-equality +# --warn-redundant-casts +# --warn-return-any +# --warn-unused-configs +# --warn-unused-ignores + +check_untyped_defs = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +extra_checks = true +no_implicit_reexport = true +strict_equality = true +warn_redundant_casts = true +warn_return_any = true +warn_unused_configs = true +warn_unused_ignores = true + +# Overrides for currently untyped modules +[[tool.mypy.overrides]] +module = [ + "imapclient.config", + "imapclient.datetime_util", + "imapclient.fixed_offset", + "imapclient.imap4", + "imapclient.imap_utf7", + "imapclient.imapclient", + "imapclient.interact", + "imapclient.response_lexer", + "imapclient.response_parser", + "imapclient.response_types", + "imapclient.testable_imapclient", + "imapclient.tls", + "imapclient.util", + "imapclient.version", + "interact", + "livetest", + "setup", +] +ignore_errors = true diff --git a/requirements-dev.txt b/requirements-dev.txt index acda464c..251278ac 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,3 +2,4 @@ sphinx black==22.3.0 flake8==4.0.1 isort==5.12.0 +mypy==1.5.1 diff --git a/tox.ini b/tox.ini index 3fc8c9d0..516a67c2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] skipsdist = True minversion = 3.0 -envlist=py37,py38,py39,py310,py311,black,isort,flake8 +envlist=py37,py38,py39,py310,py311,black,isort,flake8,mypy [testenv] commands=python -m unittest @@ -22,6 +22,11 @@ basepython = python3 commands = isort {posargs} . +[testenv:mypy] +basepython = python3 +commands = + mypy {posargs} + [flake8] exclude = .git,.venv,.tox,dist,doc,*egg,build, max-line-length = 88