summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
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 /mesonbuild/scripts
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 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/symbolextractor.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py
index b0a07d906..c0aa6502b 100644
--- a/mesonbuild/scripts/symbolextractor.py
+++ b/mesonbuild/scripts/symbolextractor.py
@@ -23,7 +23,7 @@ parser.add_argument('--cross-host', default=None, dest='cross_host',
help='cross compilation host platform')
parser.add_argument('args', nargs='+')
-TOOL_WARNING_FILE = None
+TOOL_WARNING_FILE: str
RELINKING_WARNING = 'Relinking will always happen on source changes.'
def dummy_syms(outfilename: str) -> None: