mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix pylint 2.0 return-related violations
Aiming to support pylint 2.0 some functions and methods must have their return statements updated in order to fix two new violations: - `useless-return` (R1711): Useless return at end of function or method Emitted when a single "return" or "return None" statement is found at the end of function or method definition. This statement can safely be removed because Python will implicitly return None - `inconsistent-return-statements` (R1710): Either all return statements in a function should return an expression, or none of them should. According to PEP8, if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable) Issue: https://pagure.io/freeipa/issue/7614 Signed-off-by: Armando Neto <abiagion@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
9222a08c28
commit
b4ad0d19a2
@ -549,6 +549,7 @@ class IPADiscovery(object):
|
||||
continue
|
||||
if realm:
|
||||
return realm
|
||||
return None
|
||||
|
||||
def ipadnssearchkrbkdc(self, domain=None):
|
||||
kdc = None
|
||||
|
@ -1160,7 +1160,7 @@ class Command(HasParam):
|
||||
cls.register_callback('interactive_prompt', callback, first)
|
||||
|
||||
def interactive_prompt_callback(self, kw):
|
||||
return
|
||||
pass
|
||||
|
||||
|
||||
class LocalOrRemote(Command):
|
||||
|
@ -2005,7 +2005,6 @@ class AccessTime(Str):
|
||||
raise ValidationError(
|
||||
name=self.get_param_name(), error=ugettext('incomplete time value')
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
class DNParam(Param):
|
||||
|
@ -140,8 +140,6 @@ class PlatformService(object):
|
||||
with open(paths.SVC_LIST_FILE, 'w') as f:
|
||||
json.dump(svc_list, f)
|
||||
|
||||
return
|
||||
|
||||
def stop(self, instance_name="", capture_output=True,
|
||||
update_service_list=True):
|
||||
"""
|
||||
@ -163,14 +161,12 @@ class PlatformService(object):
|
||||
with open(paths.SVC_LIST_FILE, 'w') as f:
|
||||
json.dump(svc_list, f)
|
||||
|
||||
return
|
||||
|
||||
def reload_or_restart(self, instance_name="", capture_output=True,
|
||||
wait=True):
|
||||
return
|
||||
pass
|
||||
|
||||
def restart(self, instance_name="", capture_output=True, wait=True):
|
||||
return
|
||||
pass
|
||||
|
||||
def is_running(self, instance_name="", wait=True):
|
||||
return False
|
||||
@ -185,22 +181,22 @@ class PlatformService(object):
|
||||
return False
|
||||
|
||||
def enable(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
def disable(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
def mask(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
def unmask(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
def install(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
def remove(self, instance_name=""):
|
||||
return
|
||||
pass
|
||||
|
||||
|
||||
class SystemdService(PlatformService):
|
||||
|
@ -177,7 +177,7 @@ class BaseTaskNamespace(object):
|
||||
"""
|
||||
Migrate pam stack configuration to authselect.
|
||||
"""
|
||||
return
|
||||
pass
|
||||
|
||||
def set_selinux_booleans(self, required_settings, backup_func=None):
|
||||
"""Set the specified SELinux booleans
|
||||
|
@ -275,8 +275,6 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
def group(cls):
|
||||
assert not hasattr(super(Configurable, cls), 'group')
|
||||
|
||||
return None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""
|
||||
Initialize the configurable.
|
||||
@ -339,7 +337,7 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
raise TypeError("{0} is not composite".format(self))
|
||||
|
||||
def _get_fallback(self):
|
||||
return None
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def _configure(self):
|
||||
@ -362,6 +360,7 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
self.validate()
|
||||
if self.__state == _EXECUTE_PENDING:
|
||||
return self.execute()
|
||||
return None
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
|
@ -746,6 +746,7 @@ class DomainValidator(object):
|
||||
logger.warning('%s', msg)
|
||||
|
||||
return entries
|
||||
return None
|
||||
|
||||
def __retrieve_trusted_domain_gc_list(self, domain):
|
||||
"""
|
||||
@ -1048,7 +1049,7 @@ class TrustDomainInstance(object):
|
||||
Only top level name and top level name exclusions are handled here.
|
||||
"""
|
||||
if not another_domain.ftinfo_records:
|
||||
return
|
||||
return None
|
||||
|
||||
ftinfo_records = []
|
||||
info = lsa.ForestTrustInformation()
|
||||
|
@ -42,6 +42,7 @@ class SyncReplConsumer(ReconnectLDAPObject, SyncreplConsumer):
|
||||
return cookie
|
||||
else:
|
||||
logger.debug('Current cookie is: None (not received yet)')
|
||||
return None
|
||||
|
||||
def syncrepl_set_cookie(self, cookie):
|
||||
logger.debug('New cookie is: %s', cookie)
|
||||
|
@ -262,7 +262,7 @@ def retrieve_potential_adtrust_agents(api):
|
||||
except (errors.DatabaseError, errors.NetworkError) as e:
|
||||
logger.error(
|
||||
"Could not retrieve a list of existing IPA masters: %s", e)
|
||||
return
|
||||
return None
|
||||
|
||||
try:
|
||||
# search for existing AD trust agents
|
||||
@ -270,7 +270,7 @@ def retrieve_potential_adtrust_agents(api):
|
||||
servrole=u'AD trust agent', all=True)['result']
|
||||
except (errors.DatabaseError, errors.NetworkError) as e:
|
||||
logger.error("Could not retrieve a list of adtrust agents: %s", e)
|
||||
return
|
||||
return None
|
||||
|
||||
dl_enabled_master_cns = {m['cn'][0] for m in dl_enabled_masters}
|
||||
adtrust_agents_cns = {m['cn'][0] for m in adtrust_agents}
|
||||
|
@ -141,6 +141,7 @@ def named_conf_get_directive(name, section=NAMED_SECTION_IPA, str_val=True):
|
||||
|
||||
if match and name == match.group('name'):
|
||||
return match.group('value')
|
||||
return None
|
||||
|
||||
|
||||
def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA,
|
||||
|
@ -174,6 +174,7 @@ def find_substring(data, value):
|
||||
for d in data:
|
||||
if d.startswith(value):
|
||||
return get_value(d)
|
||||
return None
|
||||
|
||||
|
||||
def get_defList(data):
|
||||
|
@ -126,6 +126,8 @@ class CACertManage(admintool.AdminTool):
|
||||
return self.renew()
|
||||
elif command == 'install':
|
||||
return self.install()
|
||||
else:
|
||||
raise NotImplementedError
|
||||
finally:
|
||||
api.Backend.ldap2.disconnect()
|
||||
|
||||
|
@ -246,6 +246,7 @@ class ServerCertInstall(admintool.AdminTool):
|
||||
return req_id
|
||||
except RuntimeError as e:
|
||||
raise admintool.ScriptError(str(e))
|
||||
return None
|
||||
|
||||
def check_chain(self, pkcs12_filename, pkcs12_pin, nssdb):
|
||||
# create a temp nssdb
|
||||
|
@ -63,7 +63,7 @@ def get_pkinit_request_ca():
|
||||
{'cert-file': paths.KDC_CERT})
|
||||
|
||||
if pkinit_request_id is None:
|
||||
return
|
||||
return None
|
||||
|
||||
return certmonger.get_request_value(pkinit_request_id, 'ca-name')
|
||||
|
||||
|
@ -110,7 +110,7 @@ def safe_output(attr, values):
|
||||
return 'XXXXXXXX'
|
||||
|
||||
if values is None:
|
||||
return
|
||||
return None
|
||||
|
||||
is_list = type(values) in (tuple, list)
|
||||
|
||||
|
@ -1216,6 +1216,7 @@ def find_subject_base():
|
||||
|
||||
logger.error('Unable to determine certificate subject base. '
|
||||
'certmap.conf will not be updated.')
|
||||
return None
|
||||
|
||||
|
||||
def uninstall_selfsign(ds, http):
|
||||
|
@ -319,7 +319,7 @@ class Service(object):
|
||||
def principal(self):
|
||||
if any(attr is None for attr in (self.realm, self.fqdn,
|
||||
self.service_prefix)):
|
||||
return
|
||||
return None
|
||||
|
||||
return unicode(
|
||||
kerberos.Principal(
|
||||
|
@ -929,6 +929,7 @@ class P11_Helper(object):
|
||||
if self.token_label == char_array_to_unicode(
|
||||
token_info_ptr[0].label, 32).rstrip():
|
||||
return slot
|
||||
return None
|
||||
|
||||
def finalize(self):
|
||||
"""
|
||||
|
@ -412,6 +412,7 @@ def validate_permissions(ugettext, perm):
|
||||
perm = perm.strip().lower()
|
||||
if perm not in _valid_permissions_values:
|
||||
return '"%s" is not a valid permission' % perm
|
||||
return None
|
||||
|
||||
|
||||
def _normalize_permissions(perm):
|
||||
|
@ -319,6 +319,7 @@ def validate_externalhost(ugettext, hostname):
|
||||
validate_hostname(hostname, check_fqdn=False, allow_underscore=True)
|
||||
except ValueError as e:
|
||||
return unicode(e)
|
||||
return None
|
||||
|
||||
|
||||
external_host_param = Str('externalhost*', validate_externalhost,
|
||||
|
@ -92,10 +92,10 @@ def validate_search_records_limit(ugettext, value):
|
||||
Values 0 and -1 are valid, as they represent unlimited.
|
||||
"""
|
||||
if value in {-1, 0}:
|
||||
return
|
||||
return None
|
||||
if value < 10:
|
||||
return _('must be at least 10')
|
||||
|
||||
return None
|
||||
|
||||
@register()
|
||||
class config(LDAPObject):
|
||||
|
@ -401,7 +401,7 @@ def _validate_ipnet(ugettext, ipnet):
|
||||
|
||||
def _validate_bind_aci(ugettext, bind_acis):
|
||||
if not bind_acis:
|
||||
return
|
||||
return None
|
||||
|
||||
bind_acis = bind_acis.split(';')
|
||||
if bind_acis[-1]:
|
||||
@ -422,10 +422,11 @@ def _validate_bind_aci(ugettext, bind_acis):
|
||||
return unicode(e)
|
||||
except UnboundLocalError:
|
||||
return _(u"invalid address format")
|
||||
return None
|
||||
|
||||
def _normalize_bind_aci(bind_acis):
|
||||
if not bind_acis:
|
||||
return
|
||||
return None
|
||||
bind_acis = bind_acis.split(';')
|
||||
normalized = []
|
||||
for bind_aci in bind_acis:
|
||||
@ -729,7 +730,7 @@ class DNSRecord(Str):
|
||||
vals = tuple(kw.get(part_name) for part_name in part_names)
|
||||
|
||||
if all(val is None for val in vals):
|
||||
return
|
||||
return None
|
||||
|
||||
if raise_on_none:
|
||||
for val_id,val in enumerate(vals):
|
||||
@ -789,17 +790,17 @@ class DNSRecord(Str):
|
||||
|
||||
def _rule_validatedns(self, _, value):
|
||||
if not self.validatedns:
|
||||
return
|
||||
return None
|
||||
|
||||
if value is None:
|
||||
return
|
||||
return None
|
||||
|
||||
if not self.supported:
|
||||
return _('DNS RR type "%s" is not supported by bind-dyndb-ldap plugin') \
|
||||
% self.rrtype
|
||||
|
||||
if self.parts is None:
|
||||
return
|
||||
return None
|
||||
|
||||
# validate record format
|
||||
values = self._get_part_values(value)
|
||||
@ -1282,6 +1283,8 @@ def _validate_naptr_flags(ugettext, flags):
|
||||
for flag in flags:
|
||||
if flag not in allowed_flags:
|
||||
return _('flags must be one of "S", "A", "U", or "P"')
|
||||
return None
|
||||
|
||||
|
||||
class NAPTRRecord(DNSRecord):
|
||||
rrtype = 'NAPTR'
|
||||
@ -1370,6 +1373,7 @@ def _sig_time_validator(ugettext, value):
|
||||
time.strptime(value, time_format)
|
||||
except ValueError:
|
||||
return _('the value does not follow "YYYYMMDDHHMMSS" time format')
|
||||
return None
|
||||
|
||||
|
||||
class SIGRecord(UnsupportedDNSRecord):
|
||||
@ -1460,7 +1464,7 @@ def _normalize_uri_target(uri_target):
|
||||
# RFC 7553 section 4.4: The Target MUST NOT be an empty URI ("").
|
||||
# minlength in param will detect this
|
||||
if not uri_target:
|
||||
return
|
||||
return None
|
||||
return u'"{0}"'.format(uri_target)
|
||||
|
||||
|
||||
|
@ -1284,7 +1284,7 @@ class RestClient(Backend):
|
||||
def __enter__(self):
|
||||
"""Log into the REST API"""
|
||||
if self.cookie is not None:
|
||||
return
|
||||
return None
|
||||
|
||||
# Refresh the ca_host property
|
||||
object.__setattr__(self, '_ca_host', None)
|
||||
|
@ -118,8 +118,7 @@ def is_all(options, attribute):
|
||||
value = options[attribute].lower()
|
||||
if value == 'all':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
@register()
|
||||
|
@ -127,6 +127,7 @@ def strip_ldap_prefix(uri):
|
||||
def prevalidate_filter(ugettext, value):
|
||||
if not value.startswith('(') or not value.endswith(')'):
|
||||
return _('must be enclosed in parentheses')
|
||||
return None
|
||||
|
||||
|
||||
class DNOrURL(DNParam):
|
||||
@ -148,6 +149,7 @@ def validate_type(ugettext, typestr):
|
||||
return _('"%s" is not an object type') % typestr
|
||||
if not getattr(obj, 'permission_filter_objectclasses', None):
|
||||
return _('"%s" is not a valid permission type') % typestr
|
||||
return None
|
||||
|
||||
|
||||
def _disallow_colon(option):
|
||||
@ -904,6 +906,8 @@ class permission(baseldap.LDAPObject):
|
||||
options['ipapermtargetfilter'] = list(options.get(
|
||||
'ipapermtargetfilter') or []) + filter_ops['add']
|
||||
|
||||
return None
|
||||
|
||||
def validate_permission(self, entry):
|
||||
ldap = self.Backend.ldap2
|
||||
|
||||
|
@ -72,6 +72,7 @@ def _domain_name_validator(ugettext, value):
|
||||
validate_domain_name(value, allow_slash=False)
|
||||
except ValueError as e:
|
||||
return unicode(e)
|
||||
return None
|
||||
|
||||
|
||||
@register()
|
||||
|
@ -140,8 +140,6 @@ def validate_selinuxuser_inlist(ldap, user):
|
||||
reason=_('SELinux user %(user)s not found in '
|
||||
'ordering list (in config)') % dict(user=user))
|
||||
|
||||
return
|
||||
|
||||
|
||||
@register()
|
||||
class selinuxusermap(LDAPObject):
|
||||
|
@ -196,7 +196,7 @@ def read_input(environ):
|
||||
try:
|
||||
length = int(environ.get('CONTENT_LENGTH'))
|
||||
except (ValueError, TypeError):
|
||||
return
|
||||
return None
|
||||
return environ['wsgi.input'].read(length).decode('utf-8')
|
||||
|
||||
|
||||
@ -613,13 +613,13 @@ class KerberosSession(HTTP_Status):
|
||||
ccache_name = environ.get('KRB5CCNAME')
|
||||
if ccache_name is None:
|
||||
logger.debug('no ccache, need login')
|
||||
return
|
||||
return None
|
||||
|
||||
# ... make sure we have a name ...
|
||||
principal = environ.get('GSS_NAME')
|
||||
if principal is None:
|
||||
logger.debug('no Principal Name, need login')
|
||||
return
|
||||
return None
|
||||
|
||||
# ... and use it to resolve the ccache name (Issue: 6972 )
|
||||
gss_name = gssapi.Name(principal, gssapi.NameType.kerberos_principal)
|
||||
@ -630,7 +630,7 @@ class KerberosSession(HTTP_Status):
|
||||
if not creds:
|
||||
logger.debug(
|
||||
'ccache expired or invalid, deleting session, need login')
|
||||
return
|
||||
return None
|
||||
|
||||
return ccache_name
|
||||
|
||||
|
@ -114,3 +114,5 @@ class CustodiaClient(object):
|
||||
self.keystore.set('keys/%s' % keyname, value)
|
||||
else:
|
||||
return value
|
||||
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user