mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add pylint ignore to magic config.Env attributes
pylinti 2 is having a hard time to handle name mangled, magic attributes correctly. Double under attributes like __d are internally renamed to _Env__d. After multiple failed attempts, it was easier to just add more pylint disable to the implementation. pylint 2 also thinkgs that Env.server is defined much later or the env doesn't have that member at all. Ignore the false warnings, too. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Armando Neto <abiagion@redhat.com>
This commit is contained in:
@@ -245,10 +245,12 @@ class Env(object):
|
|||||||
SET_ERROR % (self.__class__.__name__, key, value)
|
SET_ERROR % (self.__class__.__name__, key, value)
|
||||||
)
|
)
|
||||||
check_name(key)
|
check_name(key)
|
||||||
|
# pylint: disable=no-member
|
||||||
if key in self.__d:
|
if key in self.__d:
|
||||||
raise AttributeError(OVERRIDE_ERROR %
|
raise AttributeError(OVERRIDE_ERROR %
|
||||||
(self.__class__.__name__, key, self.__d[key], value)
|
(self.__class__.__name__, key, self.__d[key], value)
|
||||||
)
|
)
|
||||||
|
# pylint: enable=no-member
|
||||||
assert not hasattr(self, key)
|
assert not hasattr(self, key)
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, six.string_types):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
@@ -269,15 +271,15 @@ class Env(object):
|
|||||||
if type(value) not in (unicode, int, float, bool, type(None), DN):
|
if type(value) not in (unicode, int, float, bool, type(None), DN):
|
||||||
raise TypeError(key, value)
|
raise TypeError(key, value)
|
||||||
object.__setattr__(self, key, value)
|
object.__setattr__(self, key, value)
|
||||||
# pylint: disable=unsupported-assignment-operation
|
# pylint: disable=unsupported-assignment-operation, no-member
|
||||||
self.__d[key] = value
|
self.__d[key] = value
|
||||||
# pylint: enable=unsupported-assignment-operation
|
# pylint: enable=unsupported-assignment-operation, no-member
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"""
|
"""
|
||||||
Return the value corresponding to ``key``.
|
Return the value corresponding to ``key``.
|
||||||
"""
|
"""
|
||||||
return self.__d[key]
|
return self.__d[key] # pylint: disable=no-member
|
||||||
|
|
||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
"""
|
"""
|
||||||
@@ -300,19 +302,19 @@ class Env(object):
|
|||||||
"""
|
"""
|
||||||
Return True if instance contains ``key``; otherwise return False.
|
Return True if instance contains ``key``; otherwise return False.
|
||||||
"""
|
"""
|
||||||
return key in self.__d
|
return key in self.__d # pylint: disable=no-member
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
"""
|
"""
|
||||||
Return number of variables currently set.
|
Return number of variables currently set.
|
||||||
"""
|
"""
|
||||||
return len(self.__d)
|
return len(self.__d) # pylint: disable=no-member
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""
|
"""
|
||||||
Iterate through keys in ascending order.
|
Iterate through keys in ascending order.
|
||||||
"""
|
"""
|
||||||
for key in sorted(self.__d):
|
for key in sorted(self.__d): # pylint: disable=no-member
|
||||||
yield key
|
yield key
|
||||||
|
|
||||||
def _merge(self, **kw):
|
def _merge(self, **kw):
|
||||||
@@ -405,6 +407,7 @@ class Env(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def __doing(self, name):
|
def __doing(self, name):
|
||||||
|
# pylint: disable=no-member
|
||||||
if name in self.__done:
|
if name in self.__done:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'%s.%s() already called' % (self.__class__.__name__, name)
|
'%s.%s() already called' % (self.__class__.__name__, name)
|
||||||
@@ -412,11 +415,11 @@ class Env(object):
|
|||||||
self.__done.add(name)
|
self.__done.add(name)
|
||||||
|
|
||||||
def __do_if_not_done(self, name):
|
def __do_if_not_done(self, name):
|
||||||
if name not in self.__done:
|
if name not in self.__done: # pylint: disable=no-member
|
||||||
getattr(self, name)()
|
getattr(self, name)()
|
||||||
|
|
||||||
def _isdone(self, name):
|
def _isdone(self, name):
|
||||||
return name in self.__done
|
return name in self.__done # pylint: disable=no-member
|
||||||
|
|
||||||
def _bootstrap(self, **overrides):
|
def _bootstrap(self, **overrides):
|
||||||
"""
|
"""
|
||||||
@@ -557,7 +560,8 @@ class Env(object):
|
|||||||
self.__do_if_not_done('_bootstrap')
|
self.__do_if_not_done('_bootstrap')
|
||||||
|
|
||||||
# Merge in context config file and then default config file:
|
# Merge in context config file and then default config file:
|
||||||
if self.__d.get('mode', None) != 'dummy':
|
mode = self.__d.get('mode') # pylint: disable=no-member
|
||||||
|
if mode != 'dummy':
|
||||||
self._merge_from_file(self.conf)
|
self._merge_from_file(self.conf)
|
||||||
self._merge_from_file(self.conf_default)
|
self._merge_from_file(self.conf_default)
|
||||||
|
|
||||||
@@ -594,10 +598,12 @@ class Env(object):
|
|||||||
# and server from jsonrpc_uri so that when only server or xmlrpc_uri
|
# and server from jsonrpc_uri so that when only server or xmlrpc_uri
|
||||||
# is specified, all 3 keys have a value.)
|
# is specified, all 3 keys have a value.)
|
||||||
if 'xmlrpc_uri' not in self and 'server' in self:
|
if 'xmlrpc_uri' not in self and 'server' in self:
|
||||||
|
# pylint: disable=no-member, access-member-before-definition
|
||||||
self.xmlrpc_uri = 'https://{}/ipa/xml'.format(self.server)
|
self.xmlrpc_uri = 'https://{}/ipa/xml'.format(self.server)
|
||||||
|
|
||||||
# Derive ldap_uri from server
|
# Derive ldap_uri from server
|
||||||
if 'ldap_uri' not in self and 'server' in self:
|
if 'ldap_uri' not in self and 'server' in self:
|
||||||
|
# pylint: disable=no-member, access-member-before-definition
|
||||||
self.ldap_uri = 'ldap://{}'.format(self.server)
|
self.ldap_uri = 'ldap://{}'.format(self.server)
|
||||||
|
|
||||||
# Derive jsonrpc_uri from xmlrpc_uri
|
# Derive jsonrpc_uri from xmlrpc_uri
|
||||||
|
|||||||
@@ -72,6 +72,13 @@ ipa_class_members = {
|
|||||||
'find'
|
'find'
|
||||||
],
|
],
|
||||||
'ipalib.cli.Collector': ['__options'],
|
'ipalib.cli.Collector': ['__options'],
|
||||||
|
'ipalib.config.Env': [ # somehow needed for pylint on Python 2
|
||||||
|
'debug',
|
||||||
|
'startup_traceback',
|
||||||
|
'server',
|
||||||
|
'validate_api',
|
||||||
|
'verbose',
|
||||||
|
],
|
||||||
'ipalib.errors.ACIError': [
|
'ipalib.errors.ACIError': [
|
||||||
'info',
|
'info',
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user