URL: https://github.com/freeipa/freeipa/pull/1945 Author: abbra Title: #1945: [backport 4.6] pylint3: workaround false positives reported for W1662 Action: opened
PR body: """ 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 <aslai...@redhat.com> (cherry picked from commit c61151f6aa0c033834aed70561fc762c06176555) """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1945/head:pr1945 git checkout pr1945
From 95a4bddcbe3e16e1b1d8b1403b37a496805dca81 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy <aboko...@redhat.com> Date: Thu, 17 May 2018 17:49:27 +0300 Subject: [PATCH] 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 <aslai...@redhat.com> (cherry picked from commit c61151f6aa0c033834aed70561fc762c06176555) --- ipaclient/csrgen.py | 4 ++-- ipalib/plugable.py | 2 +- ipapython/ipaldap.py | 2 +- ipapython/ipautil.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ipaclient/csrgen.py b/ipaclient/csrgen.py index 1cf24d2273..e7573beca3 100644 --- a/ipaclient/csrgen.py +++ b/ipaclient/csrgen.py @@ -144,8 +144,8 @@ def build_template(self, rules): for rule in field_mapping.data_rules] data_sources = [] - for rule in field_mapping.data_rules: - data_source = rule.options.get('data_source') + for xrule in field_mapping.data_rules: + data_source = xrule.options.get('data_source') if data_source: data_sources.append(data_source) diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 758b67cd71..d78a607123 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -638,7 +638,7 @@ def add_package(self, package): logger.debug("importing all plugin modules in %s...", package_name) modules = getattr(package, 'modules', find_modules_in_dir(package_dir)) - modules = ['.'.join((package_name, name)) for name in modules] + modules = ['.'.join((package_name, mname)) for mname in modules] for name in modules: logger.debug("importing plugin module %s", name) diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 800c254df1..dcac32c31c 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -1226,7 +1226,7 @@ def combine_filters(cls, filters, rules='|'): assert isinstance(filters, (list, tuple)) - filters = [f for f in filters if f] + filters = [fx for fx in filters if fx] if filters and rules == cls.MATCH_NONE: # unary operator return '(%s%s)' % (cls.MATCH_NONE, cls.combine_filters(filters, cls.MATCH_ANY)) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index be89cdc56a..0de5fe8637 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -486,7 +486,7 @@ def preexec_fn(): 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,
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/freeipa-devel@lists.fedorahosted.org/message/OOXC6UXCLGY2FDJXMZBLCY2C3EVWXBY4/