summaryrefslogtreecommitdiff
path: root/run_project_tests.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2025-09-21 01:41:06 -0400
committerEli Schwartz <eschwartz93@gmail.com>2025-09-25 12:58:43 -0400
commitee0a1c6b5bb7c42096cf6ea088865dd841dec438 (patch)
tree8272b36087f4f2c9b0eab90966bee0f5978826a2 /run_project_tests.py
parent6cb9d898ebb5d0f1d619d4937b1c316400802609 (diff)
downloadmeson-ee0a1c6b5bb7c42096cf6ea088865dd841dec438.tar.gz
mypy: enable allow-redefinition-new and fix fallout
Reduces 3 errors that show up in newer mypy versions than pinned in CI. It is new since 1.16 and a likely future default for mypy 2.0. It allows things like: ``` for i in ['one', 'two', 'three']: frob_a(i) for i in [1, 2, 3]: frob_b(i) ``` since "i" is obviously used as a loop holder and its type can be freely reinvented. Note: allow-redefinition-new isn't actually about this at all, it has greater scope than loop holders and allows redefining "unannotated variables" of all kinds. No granularity in what to accept redefinition of. :P To enable this, we must also opt in to local-partial-types, which has some overlap with None-safety. Specifically: > the most common cases for partial types are variables initialized > using None, but without explicit X | None annotations. By default, mypy > won’t check partial types spanning module top level or class top level. > This flag changes the behavior to only allow partial types at local > level, therefore it disallows inferring variable type for None from two > assignments in different scopes. So with this, we also fix a couple of actual type errors this revealed. Where possible, stop None-initializing at all -- it's not strictly needed for global variables, anyway, and it's a coding error if it is possible to hit these variables without defining them first. Bug: https://github.com/python/mypy/issues/19280
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-xrun_project_tests.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index b2442703e..7067bfa0b 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -1577,11 +1577,11 @@ def detect_tools(report: bool = True) -> None:
print('{0:<{2}}: {1}'.format(tool.tool, get_version(tool), max_width))
print()
-symlink_test_dir1 = None
-symlink_test_dir2 = None
-symlink_file1 = None
-symlink_file2 = None
-symlink_file3 = None
+symlink_test_dir1: T.Optional[Path] = None
+symlink_test_dir2: T.Optional[Path] = None
+symlink_file1: T.Optional[Path] = None
+symlink_file2: T.Optional[Path] = None
+symlink_file3: T.Optional[Path] = None
def scan_test_data_symlinks() -> None:
global symlink_test_dir1, symlink_test_dir2, symlink_file1, symlink_file2, symlink_file3