From 18aeff4c1d8899885631f3ed9b7f58d098b0dcae Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 19 Jun 2024 17:31:44 +0100 Subject: [PATCH] Improve MyPy configuration Some improvments flagged by Repo-Review: https://learn.scientific-python.org/development/guides/repo-review/ 1. Remove now-default show_error_codes. 2. Enable some optional error codes with extra checks. --- pyproject.toml | 6 +++++- src/corsheaders/checks.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9bcfaee4..fb177f58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,9 +87,13 @@ source = [ show_missing = true [tool.mypy] +enable_error_code = [ + "ignore-without-code", + "redundant-expr", + "truthy-bool", +] mypy_path = "src/" namespace_packages = false -show_error_codes = true strict = true warn_unreachable = true diff --git a/src/corsheaders/checks.py b/src/corsheaders/checks.py index 7fe368ff..d25dc5f6 100644 --- a/src/corsheaders/checks.py +++ b/src/corsheaders/checks.py @@ -47,7 +47,7 @@ def check_settings(**kwargs: Any) -> list[CheckMessage]: ) if ( - not isinstance(conf.CORS_PREFLIGHT_MAX_AGE, int) + not isinstance(conf.CORS_PREFLIGHT_MAX_AGE, int) # type: ignore [redundant-expr] or conf.CORS_PREFLIGHT_MAX_AGE < 0 ): errors.append(