From 4da14918cd7ad6566f2a986d2dd1aaa87bf66198 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 2 Sep 2022 13:25:04 -0700 Subject: [PATCH] pylint: enable consider-using-in --- .pylintrc | 1 - mesonbuild/backend/backends.py | 2 +- mesonbuild/backend/ninjabackend.py | 2 +- mesonbuild/backend/vs2010backend.py | 8 ++++---- mesonbuild/cmake/traceparser.py | 2 +- mesonbuild/compilers/cpp.py | 2 +- mesonbuild/depfile.py | 2 +- mesonbuild/environment.py | 2 +- mesonbuild/mintro.py | 2 +- mesonbuild/mparser.py | 2 +- mesonbuild/rewriter.py | 2 +- 11 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.pylintrc b/.pylintrc index 605cde2a2..e0790bf50 100644 --- a/.pylintrc +++ b/.pylintrc @@ -14,7 +14,6 @@ disable= cell-var-from-loop, consider-merging-isinstance, consider-using-f-string, - consider-using-in, consider-using-max-builtin, consider-using-min-builtin, consider-using-with, diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 64c8fa1b9..53e3530a8 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1550,7 +1550,7 @@ class Backend: outdirs, install_dir_names, custom_install_dir = t.get_install_dir() # Sanity-check the outputs and install_dirs num_outdirs, num_out = len(outdirs), len(t.get_outputs()) - if num_outdirs != 1 and num_outdirs != num_out: + if num_outdirs not in {1, num_out}: m = 'Target {!r} has {} outputs: {!r}, but only {} "install_dir"s were found.\n' \ "Pass 'false' for outputs that should not be installed and 'true' for\n" \ 'using the default installation directory for an output.' diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 91ecc20e3..97334654d 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2331,7 +2331,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) deps=deps, depfile=depfile)) def generate_pch_rule_for(self, langname, compiler): - if langname != 'c' and langname != 'cpp': + if langname not in {'c', 'cpp'}: return rule = self.compiler_to_pch_rule_name(compiler) depargs = compiler.get_dependency_gen_args('$out', '$DEPFILE') diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 0440c3e97..fa97720ad 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -180,13 +180,13 @@ class Vs2010Backend(backends.Backend): def generate(self): target_machine = self.interpreter.builtin['target_machine'].cpu_family_method(None, None) - if target_machine == '64' or target_machine == 'x86_64': + if target_machine in {'64', 'x86_64'}: # amd64 or x86_64 self.platform = 'x64' elif target_machine == 'x86': # x86 self.platform = 'Win32' - elif target_machine == 'aarch64' or target_machine == 'arm64': + elif target_machine in {'aarch64', 'arm64'}: target_cpu = self.interpreter.builtin['target_machine'].cpu_method(None, None) if target_cpu == 'arm64ec': self.platform = 'arm64ec' @@ -198,13 +198,13 @@ class Vs2010Backend(backends.Backend): raise MesonException('Unsupported Visual Studio platform: ' + target_machine) build_machine = self.interpreter.builtin['build_machine'].cpu_family_method(None, None) - if build_machine == '64' or build_machine == 'x86_64': + if build_machine in {'64', 'x86_64'}: # amd64 or x86_64 self.build_platform = 'x64' elif build_machine == 'x86': # x86 self.build_platform = 'Win32' - elif build_machine == 'aarch64' or build_machine == 'arm64': + elif build_machine in {'aarch64', 'arm64'}: target_cpu = self.interpreter.builtin['build_machine'].cpu_method(None, None) if target_cpu == 'arm64ec': self.build_platform = 'arm64ec' diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index 1dd636fc8..d9b5f4586 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -498,7 +498,7 @@ class CMakeTraceParser: curr = args.pop(0) # XXX: APPEND_STRING is specifically *not* supposed to create a # list, is treating them as aliases really okay? - if curr == 'APPEND' or curr == 'APPEND_STRING': + if curr in {'APPEND', 'APPEND_STRING'}: append = True continue diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 2bb1b8442..16831c647 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -57,7 +57,7 @@ else: def non_msvc_eh_options(eh: str, args: T.List[str]) -> None: if eh == 'none': args.append('-fno-exceptions') - elif eh == 's' or eh == 'c': + elif eh in {'s', 'c'}: mlog.warning('non-MSVC compilers do not support ' + eh + ' exception handling.' + 'You may want to set eh to \'default\'.') diff --git a/mesonbuild/depfile.py b/mesonbuild/depfile.py index a8b458823..64b973f36 100644 --- a/mesonbuild/depfile.py +++ b/mesonbuild/depfile.py @@ -33,7 +33,7 @@ def parse(lines: T.Iterable[str]) -> T.List[T.Tuple[T.List[str], T.List[str]]]: out += c escape = None continue - if c == '\\' or c == '$': + if c in {'\\', '$'}: escape = c continue elif c in (' ', '\n'): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 394b08093..bf6d3748b 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -276,7 +276,7 @@ def detect_windows_arch(compilers: CompilersDict) -> str: # 32-bit and pretend like we're running under WOW64. Else, return the # actual Windows architecture that we deduced above. for compiler in compilers.values(): - if compiler.id == 'msvc' and (compiler.target == 'x86' or compiler.target == '80x86'): + if compiler.id == 'msvc' and (compiler.target in {'x86', '80x86'}): return 'x86' if compiler.id == 'clang-cl' and compiler.target == 'x86': return 'x86' diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index affaf9a75..154e603d9 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -323,7 +323,7 @@ def find_buildsystem_files_list(src_dir: str) -> T.List[str]: filelist = [] # type: T.List[str] for root, _, files in os.walk(src_dir): for f in files: - if f == 'meson.build' or f == 'meson_options.txt': + if f in {'meson.build', 'meson_options.txt'}: filelist.append(os.path.relpath(os.path.join(root, f), src_dir)) return filelist diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 0995ee887..36590cee3 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -175,7 +175,7 @@ class Lexer: span_end = loc bytespan = (span_start, span_end) match_text = mo.group() - if tid == 'ignore' or tid == 'comment': + if tid in {'ignore', 'comment'}: break elif tid == 'lparen': par_count += 1 diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 7912fc778..7d4f989e0 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -399,7 +399,7 @@ class Rewriter: def check_list(name: str) -> T.List[BaseNode]: result = [] for i in self.interpreter.targets: - if name == i['name'] or name == i['id']: + if name in {i['name'], i['id']}: result += [i] return result