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 <slev@altlinux.org>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Stanislav Levin
2021-03-25 18:52:03 +03:00
committed by Alexander Bokovoy
parent 6c1dc1b226
commit 2bec09aa03
6 changed files with 9 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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