Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport][ipa-4-8] Fix errors found by Pylint-2.4.3 #3853

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions ipaclient/discovery.py
Expand Up @@ -605,11 +605,9 @@ def ipadnssearchkrbkdc(self, domain=None):


def main():
# pylint: disable=import-outside-toplevel
import argparse
import os
from ipapython.ipa_log_manager import standard_logging_setup
# pylint: enable=import-outside-toplevel

parser = argparse.ArgumentParser(__name__)

Expand Down
8 changes: 0 additions & 8 deletions ipalib/__init__.py
Expand Up @@ -886,10 +886,8 @@ class my_command(Command):
def _enable_warnings(error=False):
"""Enable additional warnings during development
"""
# pylint: disable=import-outside-toplevel
import ctypes
import warnings
# pylint: enable=import-outside-toplevel

# get reference to Py_BytesWarningFlag from Python CAPI
byteswarnings = ctypes.c_int.in_dll( # pylint: disable=no-member
Expand Down Expand Up @@ -939,10 +937,8 @@ class API(plugable.API):
def packages(self):
if self.env.in_server:
# pylint: disable=import-error,ipa-forbidden-import
# pylint: disable=import-outside-toplevel
import ipaserver.plugins
# pylint: enable=import-error,ipa-forbidden-import
# pylint: enable=import-outside-toplevel
result = (
ipaserver.plugins,
)
Expand All @@ -952,21 +948,17 @@ def packages(self):
# https://github.com/PyCQA/pylint/issues/872
# Thus, below line was added as a workaround
result = None
# pylint: disable=import-outside-toplevel
import ipaclient.remote_plugins
import ipaclient.plugins
# pylint: enable=import-outside-toplevel
result = (
ipaclient.remote_plugins.get_package(self),
ipaclient.plugins,
)

if self.env.context in ('installer', 'updates'):
# pylint: disable=import-error,ipa-forbidden-import
# pylint: disable=import-outside-toplevel
import ipaserver.install.plugins
# pylint: enable=import-error,ipa-forbidden-import
# pylint: enable=import-outside-toplevel
result += (ipaserver.install.plugins,)

return result
Expand Down
6 changes: 3 additions & 3 deletions ipalib/install/certmonger.py
Expand Up @@ -347,13 +347,13 @@ def request_and_wait_for_cert(
# probably unrecoverable error
logger.debug("Giving up on cert request %s", req_id)
break
elif not resubmit_timeout:
if not resubmit_timeout:
# no resubmit
break
elif time.time() > deadline:
if time.time() > deadline:
logger.debug("Request %s reached resubmit deadline", req_id)
break
elif state == 'TIMEOUT':
if state == 'TIMEOUT':
logger.debug("%s not in final state, continue waiting", req_id)
time.sleep(10)
else:
Expand Down
4 changes: 2 additions & 2 deletions ipapython/install/common.py
Expand Up @@ -35,12 +35,12 @@ class Installable(core.Configurable):

def _get_components(self):
components = super(Installable, self)._get_components()
if self.uninstalling:
if self.uninstalling: # pylint: disable=using-constant-test
components = reversed(list(components))
return components

def _configure(self):
if self.uninstalling:
if self.uninstalling: # pylint: disable=using-constant-test
return self._uninstall()
else:
return self._install()
Expand Down
5 changes: 2 additions & 3 deletions ipaserver/install/ldapupdate.py
Expand Up @@ -521,9 +521,8 @@ def emit_plugin_update(update):
if source_line.startswith(' '):
logical_line += source_line[1:]
continue
else:
emit_item(logical_line)
logical_line = source_line
emit_item(logical_line)
logical_line = source_line

if dn is not None:
emit_item(logical_line)
Expand Down
3 changes: 1 addition & 2 deletions ipaserver/install/plugins/adtrust.py
Expand Up @@ -815,8 +815,7 @@ def execute(self, **options):
self.copy_key(paths.SAMBA_KEYTAB, hostkey)
copied = True
break
else:
uptodate = True
uptodate = True
if not (copied or uptodate):
self.copy_key(paths.SAMBA_KEYTAB, hostkey)

Expand Down
3 changes: 1 addition & 2 deletions ipaserver/install/plugins/update_managed_permissions.py
Expand Up @@ -560,8 +560,7 @@ def _pop_targetattr(aci):
if current_aci != default_aci:
logger.debug('ACIs not compatible')
continue
else:
all_incompatible = False
all_incompatible = False

if attrs_in_all_defaults is None:
attrs_in_all_defaults = set(default_attrs)
Expand Down
2 changes: 1 addition & 1 deletion ipaserver/install/server/__init__.py
Expand Up @@ -452,7 +452,7 @@ def __init__(self, **kwargs):
"You cannot specify --external-ca-profile without "
"--external-ca")

if self.uninstalling:
if self.uninstalling: # pylint: disable=using-constant-test
if (self.realm_name or self.admin_password or
self.master_password):
raise RuntimeError(
Expand Down
2 changes: 1 addition & 1 deletion ipaserver/install/server/replicainstall.py
Expand Up @@ -494,7 +494,7 @@ def promote_openldap_conf(hostname, master):
for opt in old_opts:
if opt['type'] == 'comment' and master in opt['value']:
continue
elif (opt['type'] == 'option' and opt['name'] == 'URI' and
if (opt['type'] == 'option' and opt['name'] == 'URI' and
master in opt['value']):
continue
new_opts.append(opt)
Expand Down
2 changes: 1 addition & 1 deletion ipaserver/install/service.py
Expand Up @@ -459,7 +459,7 @@ def export_ca_certs_file(self, cafile, ca_is_configured, conn=None):
pass
else:
with open(cafile, 'wb') as fd:
for cert, _unused, _unused, _unused in ca_certs:
for cert, _unused1, _unused2, _unused3 in ca_certs:
fd.write(cert.public_bytes(x509.Encoding.PEM))

def export_ca_certs_nssdb(self, db, ca_is_configured, conn=None):
Expand Down
4 changes: 2 additions & 2 deletions ipaserver/plugins/config.py
Expand Up @@ -495,7 +495,7 @@ def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
for field in entry_attrs[k].split(',')]
# test if all base types (without sub-types) are allowed
for a in attributes:
a, _dummy, _dummy = a.partition(';')
a, _unused1, _unused2 = a.partition(';')
if a not in allowed_attrs:
raise errors.ValidationError(
name=k, error=_('attribute "%s" not allowed') % a
Expand Down Expand Up @@ -527,7 +527,7 @@ def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
if self.api.Object[obj].uuid_attribute:
checked_attrs = checked_attrs + [self.api.Object[obj].uuid_attribute]
for obj_attr in checked_attrs:
obj_attr, _dummy, _dummy = obj_attr.partition(';')
obj_attr, _unused1, _unused2 = obj_attr.partition(';')
if obj_attr in OPERATIONAL_ATTRIBUTES:
continue
if obj_attr in self.api.Object[obj].params and \
Expand Down
2 changes: 1 addition & 1 deletion ipaserver/plugins/delegation.py
Expand Up @@ -113,7 +113,7 @@ def __json__(self):
)
json_dict['primary_key'] = self.primary_key.name

json_dict['methods'] = [m for m in self.methods]
json_dict['methods'] = list(self.methods)
return json_dict

def postprocess_result(self, result):
Expand Down
2 changes: 1 addition & 1 deletion ipaserver/plugins/selfservice.py
Expand Up @@ -105,7 +105,7 @@ def __json__(self):
(a, getattr(self, a)) for a in json_friendly_attributes
)
json_dict['primary_key'] = self.primary_key.name
json_dict['methods'] = [m for m in self.methods]
json_dict['methods'] = list(self.methods)
return json_dict

def postprocess_result(self, result):
Expand Down
3 changes: 1 addition & 2 deletions ipaserver/plugins/trust.py
Expand Up @@ -363,8 +363,7 @@ def add_range(myapi, trustinstance, range_name, dom_sid, *keys, **options):
if info_list:
info = info_list[0]
break
else:
sleep(2)
sleep(2)

required_msSFU_attrs = ['msSFU30MaxUidNumber', 'msSFU30OrderNumber']

Expand Down
5 changes: 2 additions & 3 deletions ipatests/pytest_ipa/integration/tasks.py
Expand Up @@ -1350,9 +1350,8 @@ def wait_for_cleanallruv_tasks(ldap, timeout=30):
):
logger.debug("All cleanallruv tasks finished successfully")
break
else:
logger.debug("cleanallruv task in progress, (waited %s/%ss)",
i, timeout)
logger.debug("cleanallruv task in progress, (waited %s/%ss)",
i, timeout)
time.sleep(1)
else:
logger.error('Giving up waiting for cleanallruv to finish')
Expand Down
4 changes: 2 additions & 2 deletions ipatests/test_integration/test_caless.py
Expand Up @@ -130,11 +130,11 @@ def install(cls, mh):
cls.cert_password = cls.master.config.admin_password
cls.crl_path = os.path.join(cls.master.config.test_dir, 'crl')

if cls.replicas:
if cls.replicas: # pylint: disable=using-constant-test
replica_hostname = cls.replicas[0].hostname
else:
replica_hostname = 'unused-replica.test'
if cls.clients:
if cls.clients: # pylint: disable=using-constant-test
client_hostname = cls.clients[0].hostname
else:
client_hostname = 'unused-client.test'
Expand Down
6 changes: 3 additions & 3 deletions ipatests/test_ipatests_plugins/test_slicing.py
Expand Up @@ -39,9 +39,9 @@ def {func}():
"nslices,nslices_d,groups",
[(2, 0, [[x for x in range(MODS_NUM) if x % 2 == 0],
[x for x in range(MODS_NUM) if x % 2 != 0]]),
(2, 1, [[0], [x for x in range(1, MODS_NUM)]]),
(1, 0, [[x for x in range(MODS_NUM)]]),
(1, 1, [[x for x in range(MODS_NUM)]]),
(2, 1, [[0], list(range(1, MODS_NUM))]),
(1, 0, [list(range(MODS_NUM))]),
(1, 1, [list(range(MODS_NUM))]),
(MODS_NUM, MODS_NUM, [[x] for x in range(MODS_NUM)]),
])
def test_slicing(ipatestdir, nslices, nslices_d, groups):
Expand Down
2 changes: 1 addition & 1 deletion ipatests/test_xmlrpc/test_certmap_plugin.py
Expand Up @@ -206,7 +206,7 @@ def certmap_user(request):

def addcertmap_id(options):
if options:
return u', '.join([k for k in options])
return u', '.join(list(options))
else:
return u' '

Expand Down
1 change: 1 addition & 0 deletions pylintrc
Expand Up @@ -101,6 +101,7 @@ disable=
keyword-arg-before-vararg, # pylint 2.0, remove after dropping Python 2
consider-using-enumerate, # pylint 2.1, clean up tests later
no-else-raise, # python 2.4.0
import-outside-toplevel, # pylint 2.4.2

[REPORTS]

Expand Down