pylint3: workaround false positives reported for W1662

Pylint3 falsely reports warning W1662: using a variable that was bound
inside a comprehension for the cases where the same name is reused for a
loop after the comprehension in question.

Rename the variable in a loop to avoid it.

If the code looks like the following:

  arr = [f for f in filters if callable(f)]
  for f in arr:
      result = result + f()

pylint3 would consider 'f' used outside of comprehension. Clearly, this
is a false-positive warning as the second 'f' use is completely
independent of the comprehension's use of 'f'.

Reviewed-By: Aleksei Slaikovskii <aslaikov@redhat.com>
This commit is contained in:
Alexander Bokovoy
2018-05-17 16:55:42 -04:00
committed by Rob Crittenden
parent a0eaa74234
commit c61151f6aa
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -496,7 +496,7 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
pent = pwd.getpwnam(runas)
suplementary_gids = [
grp.getgrnam(group).gr_gid for group in suplementary_groups
grp.getgrnam(sgroup).gr_gid for sgroup in suplementary_groups
]
logger.debug('runas=%s (UID %d, GID %s)', runas,