pylint: enable use-maxsplit-arg

This finds a bunch of places where we can do more efficient string
splitting.
pull/10783/head
Dylan Baker 3 years ago committed by Eli Schwartz
parent b11cf2f371
commit 188c552dcf
  1. 1
      .pylintrc
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 4
      mesonbuild/compilers/detect.py
  4. 2
      mesonbuild/compilers/rust.py
  5. 6
      mesonbuild/linkers/detect.py
  6. 2
      mesonbuild/linkers/linkers.py
  7. 2
      mesonbuild/modules/qt.py
  8. 2
      mesonbuild/scripts/depfixer.py

@ -88,7 +88,6 @@ disable=
use-dict-literal, use-dict-literal,
use-implicit-booleaness-not-comparison, use-implicit-booleaness-not-comparison,
use-list-literal, use-list-literal,
use-maxsplit-arg,
use-sequence-for-iteration, use-sequence-for-iteration,
used-before-assignment, used-before-assignment,
useless-return, useless-return,

@ -3554,7 +3554,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
ancestor_child = '_'.join(parents) ancestor_child = '_'.join(parents)
if ancestor_child not in tdeps: if ancestor_child not in tdeps:
raise MesonException("submodule {} relies on ancestor module {} that was not found.".format(submodmatch.group(2).lower(), ancestor_child.split('_')[0])) raise MesonException("submodule {} relies on ancestor module {} that was not found.".format(submodmatch.group(2).lower(), ancestor_child.split('_', maxsplit=1)[0]))
submodsrcfile = srcdir / tdeps[ancestor_child].fname # type: Path submodsrcfile = srcdir / tdeps[ancestor_child].fname # type: Path
if not submodsrcfile.is_file(): if not submodsrcfile.is_file():
if submodsrcfile.name != src.name: # generated source file if submodsrcfile.name != src.name: # generated source file

@ -473,7 +473,7 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
break break
else: else:
raise EnvironmentException(f'Failed to detect MSVC compiler version: stderr was\n{err!r}') raise EnvironmentException(f'Failed to detect MSVC compiler version: stderr was\n{err!r}')
cl_signature = lookat.split('\n')[0] cl_signature = lookat.split('\n', maxsplit=1)[0]
match = re.search(r'.*(x86|x64|ARM|ARM64)([^_A-Za-z0-9]|$)', cl_signature) match = re.search(r'.*(x86|x64|ARM|ARM64)([^_A-Za-z0-9]|$)', cl_signature)
if match: if match:
target = match.group(1) target = match.group(1)
@ -593,7 +593,7 @@ def detect_cuda_compiler(env: 'Environment', for_machine: MachineChoice) -> Comp
# - CUDA Toolkit 8.0.61 requires NVIDIA Driver 375.26 # - CUDA Toolkit 8.0.61 requires NVIDIA Driver 375.26
# Luckily, the "V" also makes it very simple to extract # Luckily, the "V" also makes it very simple to extract
# the full version: # the full version:
version = out.strip().split('V')[-1] version = out.strip().rsplit('V', maxsplit=1)[-1]
cpp_compiler = detect_cpp_compiler(env, for_machine) cpp_compiler = detect_cpp_compiler(env, for_machine)
cls = CudaCompiler cls = CudaCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env) env.coredata.add_lang_args(cls.language, cls, for_machine, env)

@ -111,7 +111,7 @@ class RustCompiler(Compiler):
def get_sysroot(self) -> str: def get_sysroot(self) -> str:
cmd = self.exelist + ['--print', 'sysroot'] cmd = self.exelist + ['--print', 'sysroot']
p, stdo, stde = Popen_safe(cmd) p, stdo, stde = Popen_safe(cmd)
return stdo.split('\n')[0] return stdo.split('\n', maxsplit=1)[0]
def get_debug_args(self, is_debug: bool) -> T.List[str]: def get_debug_args(self, is_debug: bool) -> T.List[str]:
return clike_debug_args[is_debug] return clike_debug_args[is_debug]

@ -83,7 +83,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
check_args.extend(extra_args) check_args.extend(extra_args)
p, o, _ = Popen_safe(compiler + check_args) p, o, _ = Popen_safe(compiler + check_args)
if 'LLD' in o.split('\n')[0]: if 'LLD' in o.split('\n', maxsplit=1)[0]:
if '(compatible with GNU linkers)' in o: if '(compatible with GNU linkers)' in o:
return LLVMDynamicLinker( return LLVMDynamicLinker(
compiler, for_machine, comp_class.LINKER_PREFIX, compiler, for_machine, comp_class.LINKER_PREFIX,
@ -98,7 +98,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
# We've already hanedled the non-direct case above # We've already hanedled the non-direct case above
p, o, e = Popen_safe(compiler + check_args) p, o, e = Popen_safe(compiler + check_args)
if 'LLD' in o.split('\n')[0]: if 'LLD' in o.split('\n', maxsplit=1)[0]:
return ClangClDynamicLinker( return ClangClDynamicLinker(
for_machine, [], for_machine, [],
prefix=comp_class.LINKER_PREFIX if use_linker_prefix else [], prefix=comp_class.LINKER_PREFIX if use_linker_prefix else [],
@ -164,7 +164,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
v = search_version(o + e) v = search_version(o + e)
linker: DynamicLinker linker: DynamicLinker
if 'LLD' in o.split('\n')[0]: if 'LLD' in o.split('\n', maxsplit=1)[0]:
linker = LLVMDynamicLinker( linker = LLVMDynamicLinker(
compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
elif 'Snapdragon' in e and 'LLVM' in e: elif 'Snapdragon' in e and 'LLVM' in e:

@ -1475,7 +1475,7 @@ class CudaLinker(PosixDynamicLinkerMixin, DynamicLinker):
# Built on Sun_Sep_30_21:09:22_CDT_2018 # Built on Sun_Sep_30_21:09:22_CDT_2018
# Cuda compilation tools, release 10.0, V10.0.166 # Cuda compilation tools, release 10.0, V10.0.166
# we need the most verbose version output. Luckily starting with V # we need the most verbose version output. Luckily starting with V
return out.strip().split('V')[-1] return out.strip().rsplit('V', maxsplit=1)[-1]
def get_accepts_rsp(self) -> bool: def get_accepts_rsp(self) -> bool:
# nvcc does not support response files # nvcc does not support response files

@ -158,7 +158,7 @@ class QtBaseModule(ExtensionModule):
care = out care = out
else: else:
care = err care = err
return care.split(' ')[-1].replace(')', '').strip() return care.rsplit(' ', maxsplit=1)[-1].replace(')', '').strip()
p = state.find_program(b, required=False, p = state.find_program(b, required=False,
version_func=get_version, version_func=get_version,

@ -306,7 +306,7 @@ class Elf(DataSizes):
self.bf.seek(offset) self.bf.seek(offset)
name = self.read_str() name = self.read_str()
if name.startswith(prefix): if name.startswith(prefix):
basename = name.split(b'/')[-1] basename = name.rsplit(b'/', maxsplit=1)[-1]
padding = b'\0' * (len(name) - len(basename)) padding = b'\0' * (len(name) - len(basename))
newname = basename + padding newname = basename + padding
assert len(newname) == len(name) assert len(newname) == len(name)

Loading…
Cancel
Save