adjust incorrect None checks for mypy strict_optional

Remove them, or convert isinstance checks to "is not None".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini authored and Paolo Bonzini committed 2026-09-10 08:32:38 +02:00
1 parent 81c998f7d7
commit a5089f2cb6
6 files changed
+5 -16

No files matched your search

+1 -7
View File
@@ -2173,13 +2173,7 @@ class Vs2010Backend(backends.Backend):
if 'masm' not in target.compilers:
return None
if target.for_machine == MachineChoice.BUILD:
platform = self.build_platform
elif target.for_machine == MachineChoice.HOST:
platform = self.platform
else:
return None
platform = self.build_platform if target.for_machine is MachineChoice.BUILD else self.platform
if platform in {'ARM', 'arm64', 'arm64ec'}:
return 'marmasm'
else:
+1 -1
View File
@@ -346,7 +346,7 @@ class ConverterTarget:
self.override_options += [f'{i}_std={std}']
elif j in {'-fPIC', '-fpic', '-fPIE', '-fpie'}:
self.pie = True
elif isinstance(ctgt, ConverterCustomTarget):
elif ctgt is not None:
# Sometimes projects pass generated source files as compiler
# flags. Add these as generated sources to ensure that the
# corresponding custom target is run.2
+1 -1
View File
@@ -155,7 +155,7 @@ class FortranCompiler(CLikeCompiler, Compiler):
# If no bounds are given, compute them in the limit of int32
maxint = 0x7fffffff
minint = -0x80000000
if not isinstance(low, int) or not isinstance(high, int):
if low is None or high is None:
if self._compile_int(f'{expression} >= 0', prefix, extra_args, dependencies):
low = cur = 0
while self._compile_int(f'{expression} > {cur}', prefix, extra_args, dependencies):
+1 -1
View File
@@ -453,7 +453,7 @@ class CLikeCompiler(Compiler):
# If no bounds are given, compute them in the limit of int32
maxint = 0x7fffffff
minint = -0x80000000
if not isinstance(low, int) or not isinstance(high, int):
if low is None or high is None:
if self._compile_int(f'{expression} >= 0', prefix, extra_args, dependencies):
low = cur = 0
while self._compile_int(f'{expression} > {cur}', prefix, extra_args, dependencies):
-2
View File
@@ -422,8 +422,6 @@ def run(options: argparse.Namespace) -> int:
project = cls(dist_name, src_root, bld_root, b.dist_scripts, subprojects, options)
names = project.create_dist(archives)
if names is None:
return 1
rc = 0
if not options.no_tests:
# Check only one.
+1 -4
View File
@@ -93,10 +93,7 @@ class DlangModule(ExtensionModule):
ret, res = self._call_dubbin(['describe', name])
if ret == 0:
version = dep.get_version()
if version is None:
data[name] = ''
else:
data[name] = version
data[name] = version
config[key] = data
else:
def _do_validate(v: object) -> _JSONTypes: