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
pull/7763/head
Dylan Baker 4年前
コミット cb0265a6b2
  1. 4
      .pylintrc
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 2
      mesonbuild/build.py

@ -6,4 +6,6 @@ score=no
[MESSAGES CONTROL]
disable=all
enable=unreachable
enable=
len-as-condition,
unreachable

@ -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):

@ -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)

読み込み中…
キャンセル
保存