Browse Source

pylint: Catch cases of `if len(container)` which should be replaced by `if container`

Unfortunately this doesn't catch other abuses of len(continauer) like,
`len(container) <comparator> 0`, see: https://github.com/PyCQA/pylint/issues/3751
tags/0.56.0.rc1
Dylan Baker 1 month ago
parent
commit
cb0265a6b2
3 changed files with 5 additions and 3 deletions
  1. +3
    -1
      .pylintrc
  2. +1
    -1
      mesonbuild/backend/ninjabackend.py
  3. +1
    -1
      mesonbuild/build.py

+ 3
- 1
.pylintrc View File

@@ -6,4 +6,6 @@ score=no

[MESSAGES CONTROL]
disable=all
enable=unreachable
enable=
len-as-condition,
unreachable

+ 1
- 1
mesonbuild/backend/ninjabackend.py View File

@@ -2587,7 +2587,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))

def get_link_whole_args(self, linker, target):
target_args = self.build_target_link_arguments(linker, target.link_whole_targets)
return linker.get_link_whole_for(target_args) if len(target_args) else []
return linker.get_link_whole_for(target_args) if target_args else []

@lru_cache(maxsize=None)
def guess_library_absolute_path(self, linker, libname, search_dirs, patterns):


+ 1
- 1
mesonbuild/build.py View File

@@ -2232,7 +2232,7 @@ class CustomTarget(Target):
def get_dep_outname(self, infilenames):
if self.depfile is None:
raise InvalidArguments('Tried to get depfile name for custom_target that does not have depfile defined.')
if len(infilenames):
if infilenames:
plainname = os.path.basename(infilenames[0])
basename = os.path.splitext(plainname)[0]
return self.depfile.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname)


Loading…
Cancel
Save