diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-08-15 11:08:26 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-10-04 16:29:30 -0400 |
commit | e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca (patch) | |
tree | 83ed77c6e7372b73fc7f84cb326fd95808335be8 /mesonbuild | |
parent | 2d65472c725f18b343aee00bf91b9ac98c08b95f (diff) | |
download | meson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.zip meson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.tar.gz meson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.tar.bz2 |
various python neatness cleanups
All changes were created by running
"pyupgrade --py3-only"
and committing the results. Although this has been performed in the
past, newer versions of pyupgrade can automatically catch more
opportunities, notably list comprehensions can use generators instead,
in the following cases:
- unpacking into function arguments as function(*generator)
- unpacking into assignments of the form x, y = generator
- as the argument to some builtin functions such as min/max/sorted
Also catch a few creeping cases of new code added using older styles.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/build.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/base.py | 4 | ||||
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreter/type_checking.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/unstable_cuda.py | 2 | ||||
-rw-r--r-- | mesonbuild/mtest.py | 6 | ||||
-rw-r--r-- | mesonbuild/scripts/clangformat.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/clangtidy.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/depscan.py | 2 |
10 files changed, 14 insertions, 14 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c2649ad..dd31527 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1035,7 +1035,7 @@ class BuildTarget(Target): self.link_whole(linktarget) c_pchlist, cpp_pchlist, clist, cpplist, cudalist, cslist, valalist, objclist, objcpplist, fortranlist, rustlist \ - = [extract_as_list(kwargs, c) for c in ['c_pch', 'cpp_pch', 'c_args', 'cpp_args', 'cuda_args', 'cs_args', 'vala_args', 'objc_args', 'objcpp_args', 'fortran_args', 'rust_args']] + = (extract_as_list(kwargs, c) for c in ['c_pch', 'cpp_pch', 'c_args', 'cpp_args', 'cuda_args', 'cs_args', 'vala_args', 'objc_args', 'objcpp_args', 'fortran_args', 'rust_args']) self.add_pch('c', c_pchlist) self.add_pch('cpp', cpp_pchlist) @@ -2456,7 +2456,7 @@ class CustomTarget(Target, CommandBase): self.build_always_stale = kwargs['build_always_stale'] if not isinstance(self.build_always_stale, bool): raise InvalidArguments('Argument build_always_stale must be a boolean.') - extra_deps, depend_files = [extract_as_list(kwargs, c, pop=False) for c in ['depends', 'depend_files']] + extra_deps, depend_files = (extract_as_list(kwargs, c, pop=False) for c in ['depends', 'depend_files']) for ed in extra_deps: if not isinstance(ed, (CustomTarget, BuildTarget)): raise InvalidArguments('Can only depend on toplevel targets: custom_target or build_target ' diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 870d164..0b6f544 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -127,7 +127,7 @@ class Dependency(HoldableObject): def get_all_compile_args(self) -> T.List[str]: """Get the compile arguments from this dependency and it's sub dependencies.""" return list(itertools.chain(self.get_compile_args(), - *[d.get_all_compile_args() for d in self.ext_deps])) + *(d.get_all_compile_args() for d in self.ext_deps))) def get_link_args(self, language: T.Optional[str] = None, raw: bool = False) -> T.List[str]: if raw and self.raw_link_args is not None: @@ -137,7 +137,7 @@ class Dependency(HoldableObject): def get_all_link_args(self) -> T.List[str]: """Get the link arguments from this dependency and it's sub dependencies.""" return list(itertools.chain(self.get_link_args(), - *[d.get_all_link_args() for d in self.ext_deps])) + *(d.get_all_link_args() for d in self.ext_deps))) def found(self) -> bool: return self.is_found diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index 70a2d18..e595daf 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -574,7 +574,7 @@ class CompilerHolder(ObjectHolder['Compiler']): KwargInfo('static', (bool, NoneType), since='0.51.0'), KwargInfo('disabler', bool, default=False, since='0.49.0'), KwargInfo('dirs', ContainerTypeInfo(list, str), listify=True, default=[]), - *[k.evolve(name=f'header_{k.name}') for k in _HEADER_KWS] + *(k.evolve(name=f'header_{k.name}') for k in _HEADER_KWS) ) def find_library_method(self, args: T.Tuple[str], kwargs: 'FindLibraryKW') -> 'dependencies.ExternalLibrary': # TODO add dependencies support? diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 46910dd..0b40611 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -90,7 +90,7 @@ def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) - emtpy FileMode. """ # this has already been validated by the validator - return FileMode(*[m if isinstance(m, str) else None for m in mode]) + return FileMode(*(m if isinstance(m, str) else None for m in mode)) def _lower_strlist(input: T.List[str]) -> T.List[str]: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 1343bc7..81551ca 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -184,7 +184,7 @@ class GnomeModule(ExtensionModule): glib_compile_resources = state.find_program('glib-compile-resources') cmd = [glib_compile_resources, '@INPUT@'] - source_dirs, dependencies = [mesonlib.extract_as_list(kwargs, c, pop=True) for c in ['source_dir', 'dependencies']] + source_dirs, dependencies = (mesonlib.extract_as_list(kwargs, c, pop=True) for c in ['source_dir', 'dependencies']) if len(args) < 2: raise MesonException('Not enough arguments; the name of the resource ' diff --git a/mesonbuild/modules/unstable_cuda.py b/mesonbuild/modules/unstable_cuda.py index 920457d..63c7f85 100644 --- a/mesonbuild/modules/unstable_cuda.py +++ b/mesonbuild/modules/unstable_cuda.py @@ -264,7 +264,7 @@ class CudaModule(NewExtensionModule): elif isinstance(cuda_arch_list, str): cuda_arch_list = self._break_arch_string(cuda_arch_list) - cuda_arch_list = sorted([x for x in set(cuda_arch_list) if x]) + cuda_arch_list = sorted(x for x in set(cuda_arch_list) if x) cuda_arch_bin = [] cuda_arch_ptx = [] diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index fd175ba..f877ec8 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1660,7 +1660,7 @@ class TestHarness: # wrapper script. sys.exit(125) - self.name_max_len = max([uniwidth(self.get_pretty_suite(test)) for test in tests]) + self.name_max_len = max(uniwidth(self.get_pretty_suite(test)) for test in tests) startdir = os.getcwd() try: os.chdir(self.options.wd) @@ -1668,8 +1668,8 @@ class TestHarness: for i in range(self.options.repeat): runners.extend(self.get_test_runner(test) for test in tests) if i == 0: - self.duration_max_len = max([len(str(int(runner.timeout or 99))) - for runner in runners]) + self.duration_max_len = max(len(str(int(runner.timeout or 99))) + for runner in runners) # Disable the progress report if it gets in the way self.need_console = any(runner.console_mode is not ConsoleUser.LOGGER for runner in runners) diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index 8e61b55..518d44c 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -70,7 +70,7 @@ def clangformat(exelist: T.List[str], srcdir: Path, builddir: Path, check: bool) any(fnmatch.fnmatch(strf, i) for i in ignore): continue futures.append(e.submit(run_clang_format, exelist, f, check)) - returncode = max([x.result().returncode for x in futures]) + returncode = max(x.result().returncode for x in futures) return returncode def run(args: T.List[str]) -> int: diff --git a/mesonbuild/scripts/clangtidy.py b/mesonbuild/scripts/clangtidy.py index 8d366c8..d1732a3 100644 --- a/mesonbuild/scripts/clangtidy.py +++ b/mesonbuild/scripts/clangtidy.py @@ -36,7 +36,7 @@ def manual_clangtidy(srcdir_name: str, builddir_name: str) -> int: if strf.startswith(builddir_name): continue futures.append(e.submit(subprocess.run, ['clang-tidy', '-p', builddir_name, strf])) - returncode = max([x.result().returncode for x in futures]) + returncode = max(x.result().returncode for x in futures) return returncode def clangtidy(srcdir_name: str, builddir_name: str) -> int: diff --git a/mesonbuild/scripts/depscan.py b/mesonbuild/scripts/depscan.py index f2ec0bd..c80a5bc 100644 --- a/mesonbuild/scripts/depscan.py +++ b/mesonbuild/scripts/depscan.py @@ -197,7 +197,7 @@ class DependencyScanner: def run(args: T.List[str]) -> int: assert len(args) == 3, 'got wrong number of arguments!' pickle_file, outfile, jsonfile = args - with open(jsonfile, 'r', encoding='utf-8') as f: + with open(jsonfile, encoding='utf-8') as f: sources = json.load(f) scanner = DependencyScanner(pickle_file, outfile, sources) return scanner.scan() |