From b11cf2f37165ddf0ebe737e85768483ff4387481 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 2 Sep 2022 11:42:08 -0700 Subject: [PATCH] pylint: enable consider-using-dict-items Which found a couple of places where we could write better code. --- .pylintrc | 1 - mesonbuild/backend/vs2010backend.py | 9 ++++----- mesonbuild/mintro.py | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.pylintrc b/.pylintrc index 5fda1f9d5159..659d88596667 100644 --- a/.pylintrc +++ b/.pylintrc @@ -13,7 +13,6 @@ disable= broad-except, cell-var-from-loop, consider-merging-isinstance, - consider-using-dict-items, consider-using-f-string, consider-using-in, consider-using-max-builtin, diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 017a509353cd..0440c3e97040 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -1360,9 +1360,8 @@ def path_normalize_add(path, lis): relpath = os.path.join(down, h.rel_to_builddir(self.build_to_src)) if path_normalize_add(relpath, previous_includes): ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath) - for lang in pch_sources: - h = pch_sources[lang][0] - path = os.path.join(proj_to_src_dir, h) + for headers in pch_sources.values(): + path = os.path.join(proj_to_src_dir, headers[0]) if path_normalize_add(path, previous_includes): ET.SubElement(inc_hdrs, 'CLInclude', Include=path) @@ -1391,8 +1390,8 @@ def path_normalize_add(path, lis): s = File.from_built_file(target.get_subdir(), s) ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + \ self.object_filename_from_source(target, s) - for lang in pch_sources: - impl = pch_sources[lang][1] + for lang, headers in pch_sources.items(): + impl = headers[1] if impl and path_normalize_add(impl, previous_sources): inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=impl) self.create_pch(pch_sources, lang, inc_cl) diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 5254b3ad8b9a..affaf9a751ea 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -488,8 +488,8 @@ def run(options: argparse.Namespace) -> int: return 1 # Extract introspection information from JSON - for i in intro_types.keys(): - if not intro_types[i].func: + for i, v in intro_types.items(): + if not v.func: continue if not options.all and not getattr(options, i, False): continue @@ -549,8 +549,8 @@ def write_meson_info_file(builddata: build.Build, errors: list, build_files_upda intro_types = get_meson_introspection_types() intro_info = {} - for i in intro_types.keys(): - if not intro_types[i].func: + for i, v in intro_types.items(): + if not v.func: continue intro_info[i] = { 'file': f'intro-{i}.json',