From b849c239ae9d08158b26ff4ef30e7262df7be535 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 11 May 2022 23:51:00 -0400 Subject: [PATCH] chore: update mypy and move to toml This: * Updates mypy to 0.950 * Uses pyproject.toml insted of mypy.ini - nicer config, fewer files * Uses `strict = true` instead of the long list (supported last few versions) * Uses more precise include ignoring, and includes a couple of typing requirements * Exposes a variable type change, fixed * Adds a few extra (easy) strictness and config flags. Didn't add unreachable, since it was more involved. Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 3 ++- MANIFEST.in | 1 - mypy.ini | 17 ----------------- packaging/requirements.py | 4 ++-- pyproject.toml | 10 ++++++++++ 5 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 mypy.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d00b427..ce2e4a43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,11 +8,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.942 + rev: v0.950 hooks: - id: mypy exclude: '^(docs|tasks|tests)|setup\.py' args: [] + additional_dependencies: [pyparsing, nox] - repo: https://github.com/asottile/pyupgrade rev: v2.32.0 diff --git a/MANIFEST.in b/MANIFEST.in index a078133d..f481a3fe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,6 @@ include LICENSE LICENSE.APACHE LICENSE.BSD include .coveragerc include .flake8 include .pre-commit-config.yaml -include mypy.ini recursive-include docs * recursive-include tests *.py diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index d88ab8f1..00000000 --- a/mypy.ini +++ /dev/null @@ -1,17 +0,0 @@ -[mypy] -ignore_missing_imports = True - -# The following are the flags enabled by --strict -warn_unused_configs = True -disallow_subclassing_any = True -disallow_any_generics = True -disallow_untyped_calls = True -disallow_untyped_defs = True -disallow_incomplete_defs = True -check_untyped_defs = True -disallow_untyped_decorators = True -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -no_implicit_reexport = True diff --git a/packaging/requirements.py b/packaging/requirements.py index a0c6217e..bc0b17ca 100644 --- a/packaging/requirements.py +++ b/packaging/requirements.py @@ -20,7 +20,7 @@ stringStart, ) -from .markers import MARKER_EXPR, Marker +from .markers import MARKER_EXPR as _MARKER_EXPR, Marker from .specifiers import LegacySpecifier, Specifier, SpecifierSet @@ -66,7 +66,7 @@ class InvalidRequirement(ValueError): VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier") VERSION_SPEC.setParseAction(lambda s, l, t: t[1]) -MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") +MARKER_EXPR = originalTextFor(_MARKER_EXPR())("marker") MARKER_EXPR.setParseAction( lambda s, l, t: Marker(s[t._original_start : t._original_end]) ) diff --git a/pyproject.toml b/pyproject.toml index cb37b725..562c9d57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,13 @@ [build-system] requires = ['setuptools >= 40.8.0', 'wheel'] build-backend = 'setuptools.build_meta' + + +[tool.mypy] +strict = true +show_error_codes = true +enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] + +[[tool.mypy.overrides]] +module = ["_manylinux"] +ignore_missing_imports = true