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-implicit-booleaness-not-comparison,
use-list-literal,
use-maxsplit-arg,
use-sequence-for-iteration,
used-before-assignment,
useless-return,

@ -3554,7 +3554,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
ancestor_child = '_'.join(parents)
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
if not submodsrcfile.is_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
else:
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)
if match:
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
# Luckily, the "V" also makes it very simple to extract
# 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)
cls = CudaCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env)

@ -111,7 +111,7 @@ class RustCompiler(Compiler):
def get_sysroot(self) -> str:
cmd = self.exelist + ['--print', 'sysroot']
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]:
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)
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:
return LLVMDynamicLinker(
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
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(
for_machine, [],
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)
linker: DynamicLinker
if 'LLD' in o.split('\n')[0]:
if 'LLD' in o.split('\n', maxsplit=1)[0]:
linker = LLVMDynamicLinker(
compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
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
# Cuda compilation tools, release 10.0, V10.0.166
# 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:
# nvcc does not support response files

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

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

Loading…
Cancel
Save