From d382a3cccf4547ec61503db46ff7a316bebda581 Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Fri, 15 Nov 2024 16:27:53 +0100 Subject: [PATCH] tests: Make mypy a lot stricter The default `strict = true` is too permissive for my liking, especially how it allows using `Any` in many places and doesn't warn about them at all. --- pyproject.toml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a0120ee..86f4fe6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,8 +16,39 @@ package-dir = { "" = "src" } "*" = ["*.nix"] [tool.mypy] -strict = true mypy_path = "src" +warn_unused_configs = true +# We don't use `strict = true` but write out all individual flags because +# strict is not strict enough and its meaning may change in the future. +# See https://mypy.readthedocs.io/en/stable/config_file.html#confval-strict +# Disallow dynamic typing +disallow_any_unimported = true +disallow_any_expr = true +disallow_any_decorated = true +disallow_any_explicit = false # We need to be able to use `Any` as an input parameter to some functions +disallow_any_generics = true +disallow_subclassing_any = true +# Untyped definitions and calls +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true +# Warnings +warn_redundant_casts = true +warn_unused_ignores = true +warn_no_return = true +warn_return_any = true +warn_unreachable = true +# Miscellaneous strictness flags +no_implicit_reexport = true +strict_concatenate = true +strict_equality = true +extra_checks = true +# Error message control +show_error_context = true +show_error_code_links = true +pretty = true [tool.pytest.ini_options] pythonpath = ["src"]