ruff: Fix automatically fixable PyFlakes issues

Generated with: `ruff check --select F --fix`
This commit is contained in:
Dylan Baker authored and Paolo Bonzini committed 2026-10-24 08:13:14 +02:00
1 parent 53e38948f2
commit dad37cddba
21 files changed
+22 -33

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ class RefmanLinksExtension(Extension):
# Add Arguments with `group.add_argument(...)`
group.add_argument(
f'--refman-data-file',
'--refman-data-file',
help="JSON file with the mappings to replace",
default=None,
)
+1 -1
View File
@@ -165,7 +165,7 @@ def main() -> int:
'returned': list,
'modules': dict,
}
assert_has_typed_keys(f'root.objects_by_type', refs, expected)
assert_has_typed_keys('root.objects_by_type', refs, expected)
assert not refs, f'root.objects_by_type has extra keys: {refs.keys()}'
assert all(isinstance(x, str) for x in root['objects_by_type']['elementary'])
assert all(isinstance(x, str) for x in root['objects_by_type']['builtins'])
+1 -1
View File
@@ -2,7 +2,7 @@
# Copyright 2021 The Meson development team
from .generatorbase import GeneratorBase
from .model import ReferenceManual, Object, Function, DataTypeInfo, Type, ObjectType
from .model import Object, Function, DataTypeInfo, Type, ObjectType
from mesonbuild import mlog
import typing as T
+1 -1
View File
@@ -252,7 +252,7 @@ class LoaderYAML(LoaderBase):
def _load_object(self, obj_type: ObjectType, path: Path) -> Object:
path_label = path.relative_to(self.yaml_dir).as_posix()
mlog.log(f'Loading', mlog.bold(path_label))
mlog.log('Loading', mlog.bold(path_label))
raw = self._load(self.read_file(path), self.template.s_object, label=path_label)
def as_methods(mlist: T.List[Function]) -> T.List[Method]:
-1
View File
@@ -6,7 +6,6 @@
"""Helper functions and classes."""
import os
from .utils.core import *
from .utils.vsenv import *
+1 -1
View File
@@ -4,7 +4,7 @@
# This script only works on Jussi's private release machine.
import os, sys, subprocess, re, shutil
import os, sys, subprocess, shutil
import tarfile
from glob import glob
import pathlib
-1
View File
@@ -6,7 +6,6 @@ import os
import tempfile
import unittest
import subprocess
import zipapp
import sysconfig
from pathlib import Path
-3
View File
@@ -10,9 +10,7 @@ from mesonbuild import _pathlib
import sys
sys.modules['pathlib'] = _pathlib
import collections
import os
import time
import shutil
import subprocess
import platform
@@ -38,7 +36,6 @@ from mesonbuild.tooldetect import detect_ninja
from mesonbuild.coredata import version as meson_version
from mesonbuild.options import backendlist
from mesonbuild.mesonlib import setup_vsenv
from mesonbuild.options import OptionKey
if T.TYPE_CHECKING:
from mesonbuild.coredata import SharedCMDOptions
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import argparse
import os
def main() -> None:
+5 -5
View File
@@ -256,12 +256,12 @@ def main() -> int:
"""), ' '))
if export_modules:
print(textwrap.dedent(f'''\
}}
print(textwrap.dedent('''\
}
# dict of all modules with metadata
boost_modules = {{\
boost_modules = {\
'''))
for mod in modules:
@@ -275,8 +275,8 @@ def main() -> int:
),\
"""), ' '))
print(textwrap.dedent(f'''\
}}
print(textwrap.dedent('''\
}
# #
#### ---- END GENERATED ---- ####\
+2 -2
View File
@@ -14,9 +14,9 @@ PathLike = T.Union[Path,str]
def copy_files(files: T.List[str], input_dir: PathLike, output_dir: PathLike) -> None:
if not input_dir:
raise ValueError(f'Input directory value is not set')
raise ValueError('Input directory value is not set')
if not output_dir:
raise ValueError(f'Output directory value is not set')
raise ValueError('Output directory value is not set')
input_dir = Path(input_dir).resolve()
output_dir = Path(output_dir).resolve()
+1 -1
View File
@@ -146,7 +146,7 @@ def generate_wrapdb_table(output_dir: Path) -> None:
def regenerate_docs(output_dir: PathLike,
dummy_output_file: T.Optional[PathLike]) -> None:
if not output_dir:
raise ValueError(f'Output directory value is not set')
raise ValueError('Output directory value is not set')
output_dir = Path(output_dir).resolve()
output_dir.mkdir(parents=True, exist_ok=True)
+3 -3
View File
@@ -16,7 +16,7 @@ import pickle
import zipfile, tarfile
import sys
import sysconfig
from unittest import mock, SkipTest, skipIf, skipUnless, expectedFailure
from unittest import mock, SkipTest, skipIf, skipUnless
from contextlib import contextmanager
from glob import glob
from pathlib import (PurePath, Path)
@@ -935,7 +935,7 @@ class AllPlatformTests(BasePlatformTests):
try:
self._run(command)
self.assertEqual(0, failure_count, 'Expected %d tests to fail.' % failure_count)
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
actual_fails = 0
with open(os.path.join(self.logdir, 'testlog.json'), encoding='utf-8') as f:
for line in f:
@@ -3454,7 +3454,7 @@ class AllPlatformTests(BasePlatformTests):
with tempfile.NamedTemporaryFile(mode='w', delete=False, encoding='utf-8') as cross_file:
cross_file.write(
textwrap.dedent(f'''
textwrap.dedent('''
[binaries]
pkg-config = 'pkg-config'
''')
+1 -1
View File
@@ -238,7 +238,7 @@ class BasePlatformTests(TestCase):
if inprocess:
try:
returncode, out, err = run_configure_inprocess(['setup'] + self.meson_args + args + extra_args + build_and_src_dir_args, override_envvars)
except Exception as e:
except Exception:
if not allow_fail:
self._print_meson_log()
raise
+1 -2
View File
@@ -3,7 +3,6 @@
from __future__ import annotations
import unittest
from unittest import mock
import os
import tempfile
import textwrap
@@ -12,7 +11,7 @@ import typing as T
from mesonbuild.cargo import cfg
from mesonbuild.cargo.cfg import TokenType
from mesonbuild.cargo.interpreter import load_cargo_lock
from mesonbuild.cargo.manifest import Dependency, Lint, Manifest, Package, Workspace
from mesonbuild.cargo.manifest import Dependency, Manifest, Package, Workspace
from mesonbuild.cargo.toml import load_toml
from mesonbuild.cargo.version import api, cargo_parse, SemVer
from mesonbuild.mesonlib import MachineChoice, MesonException
+1 -2
View File
@@ -45,7 +45,7 @@ from mesonbuild.interpreterbase import (
KwargInfo, PosArgInfo, VarArgInfo,
)
from mesonbuild.mesonlib import (
FileMode, LibType, MachineChoice, PerMachine, SimpleABC, Version, is_windows, is_osx,
FileMode, LibType, MachineChoice, SimpleABC, Version, is_windows, is_osx,
is_cygwin, is_openbsd, search_version, MesonException, EnvironmentException, python_command,
version_check_to_range,
)
@@ -57,7 +57,6 @@ from mesonbuild.interpreter.type_checking import (
from mesonbuild.dependencies.pkgconfig import PkgConfigDependency, PkgConfigInterface, PkgConfigCLI
from mesonbuild.programs import ExternalProgram
import mesonbuild.modules.pkgconfig
from mesonbuild import utils
from run_tests import get_fake_env, get_fake_options
-1
View File
@@ -2,7 +2,6 @@
# Copyright 2016-2021 The Meson development team
import os
import shutil
import subprocess
import unittest
import platform
+2 -2
View File
@@ -1878,14 +1878,14 @@ class LinuxlikeTests(BasePlatformTests):
# Verify that "gcc -m32" works
try:
self.do_one_test_with_nativefile('1 trivial', "['gcc', '-m32']")
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
raise SkipTest('Not GCC, or GCC does not have the -m32 option')
self.wipe()
# Verify that cmake works
try:
self.do_one_test_with_nativefile('../cmake/1 basic', "['gcc']")
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
raise SkipTest('Could not build basic cmake project')
self.wipe()
-1
View File
@@ -8,7 +8,6 @@ import os
import pickle
import subprocess
import tempfile
import subprocess
import textwrap
import shutil
from unittest import skipIf, SkipTest
+1 -1
View File
@@ -12,7 +12,7 @@ import typing as T
from mesonbuild.ast import IntrospectionInterpreter, AstIDGenerator
from mesonbuild.ast.printer import RawPrinter
from mesonbuild.mesonlib import windows_proof_rmtree, is_windows, is_linux
from mesonbuild.mesonlib import windows_proof_rmtree
from .baseplatformtests import BasePlatformTests
from .helpers import skip_if_not_language
-1
View File
@@ -19,7 +19,6 @@ from mesonbuild.mesonlib import (
MachineChoice, is_windows, is_cygwin, python_command, version_compare,
EnvironmentException
)
from mesonbuild.options import OptionKey
from mesonbuild.compilers import (
detect_c_compiler, detect_d_compiler, compiler_from_language,
)