From 2bec09aa038d2ef8f3819f11e67ba81d70cb5fe4 Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Mar 30 2021 10:18:09 +0000 Subject: pylint: Fix several warnings Fixes Pylint warnings: - R1729(use-a-generator) - R1710(inconsistent-return-statements) - R1727(condition-evals-to-constant) Fixes: https://pagure.io/freeipa/issue/8772 Signed-off-by: Stanislav Levin Reviewed-By: Alexander Bokovoy --- diff --git a/install/tools/ipa-replica-manage.in b/install/tools/ipa-replica-manage.in index 93a13cf..880ac46 100644 --- a/install/tools/ipa-replica-manage.in +++ b/install/tools/ipa-replica-manage.in @@ -869,12 +869,12 @@ def ensure_last_services(conn, hostname, masters, options): if ca_hostname is None and 'CA' in services_cns: ca_hostname = master_cn - if 'CA' in this_services and not any(['CA' in o for o in other_services]): + if 'CA' in this_services and not any('CA' in o for o in other_services): print("Deleting this server is not allowed as it would leave your installation without a CA.") sys.exit(1) other_dns = True - if 'DNS' in this_services and not any(['DNS' in o for o in other_services]): + if 'DNS' in this_services and not any('DNS' in o for o in other_services): other_dns = False print("Deleting this server will leave your installation without a DNS.") if not options.force and not ipautil.user_input("Continue to delete?", False): diff --git a/ipalib/install/kinit.py b/ipalib/install/kinit.py index 1e1b786..a4cf0cb 100644 --- a/ipalib/install/kinit.py +++ b/ipalib/install/kinit.py @@ -63,6 +63,8 @@ def kinit_keytab(principal, keytab, ccache_name, config=None, attempts=1): else: os.environ.pop('KRB5_CONFIG', None) + return None + def kinit_password(principal, password, ccache_name, config=None, armor_ccache_name=None, canonicalize=False, enterprise=False, lifetime=None): diff --git a/ipapython/install/cli.py b/ipapython/install/cli.py index 1bcac67..53a1cfb 100644 --- a/ipapython/install/cli.py +++ b/ipapython/install/cli.py @@ -329,6 +329,8 @@ class ConfigureTool(admintool.AdminTool): except RuntimeError as e: self.option_parser.error(str(e)) + return None + def run(self): cfgr = self.init_configurator() diff --git a/ipaserver/plugins/server.py b/ipaserver/plugins/server.py index f2544a8..b3dda84 100644 --- a/ipaserver/plugins/server.py +++ b/ipaserver/plugins/server.py @@ -271,7 +271,7 @@ class server_mod(LDAPUpdate): # server is not DNS server pass - if 'ipalocation_location' or 'ipaserviceweight' in options: + if 'ipalocation_location' in options or 'ipaserviceweight' in options: self.add_message(messages.ServiceRestartRequired( service=services.service('named', api).systemd_name, server=keys[0], )) diff --git a/ipatests/test_integration/test_dns_locations.py b/ipatests/test_integration/test_dns_locations.py index aa662ab..6eac0d0 100644 --- a/ipatests/test_integration/test_dns_locations.py +++ b/ipatests/test_integration/test_dns_locations.py @@ -61,6 +61,7 @@ def resolve_records_from_server(rname, rtype, nameserver): pytest.fail("Query: {} {}, nameserver {} failed due to {}".format( rname, rtype, nameserver, error)) + return None def _gen_expected_srv_rrset(rname, port, servers, ttl=86400): diff --git a/ipatests/test_integration/test_trust.py b/ipatests/test_integration/test_trust.py index c8a3482..207cddb 100644 --- a/ipatests/test_integration/test_trust.py +++ b/ipatests/test_integration/test_trust.py @@ -313,7 +313,7 @@ class TestTrust(BaseTestTrust): result = self.master.run_command( ['su', '-', testuser, '-c', 'sudo -l']) if isinstance(expected, (tuple, list)): - assert any([x for x in expected if x in result.stdout_text]) + assert any(x for x in expected if x in result.stdout_text) else: assert expected in result.stdout_text finally: