From d8aa3e10398d0d23eefdbda899475ca32ec3abf6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 7 May 2015 12:33:40 -0400 Subject: pylint 1.4.3 version fixes Pylint 1.4.3 completely stopped recognizing the star-args condition. In order to avoid pylint error with > 1.4.3 stop caring for star-args and add cmdline option to ignore those errors completly so older pylint versions are happy too. Also fix type() vs isinstance() checks, isinstance is generally a more correct approach to check for calsses. In some 'admin' files the type() -> isinstance() fix required to invert the order in which ComplexList and MappingList are checked as the latter is a subclass of ComplexList, so it needs to be checked first otherwise the check for isinstance(option, ComplexList) matches for both and the code stops funciotning properly. Signed-off-by: Simo Sorce --- ipsilon/providers/openid/auth.py | 3 +-- ipsilon/providers/saml2/admin.py | 14 +++++++------- ipsilon/providers/saml2/auth.py | 1 - ipsilon/providers/saml2/provider.py | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'ipsilon/providers') diff --git a/ipsilon/providers/openid/auth.py b/ipsilon/providers/openid/auth.py index 2510ff4..e85890e 100644 --- a/ipsilon/providers/openid/auth.py +++ b/ipsilon/providers/openid/auth.py @@ -44,7 +44,7 @@ class AuthenticateRequest(ProviderPageBase): if args is not None: first = args[0] if len(args) > 0 else None second = first[0] if len(first) > 0 else None - if type(second) is dict: + if isinstance(second, dict): form = second.get('form', None) return form @@ -191,7 +191,6 @@ class AuthenticateRequest(ProviderPageBase): "authz_details": ad, } context.update(dict((self.trans.get_POST_tuple(),))) - # pylint: disable=star-args return self._template('openid/consent_form.html', **context) def _response(self, request, session): diff --git a/ipsilon/providers/saml2/admin.py b/ipsilon/providers/saml2/admin.py index 158e590..5ab8f7e 100644 --- a/ipsilon/providers/saml2/admin.py +++ b/ipsilon/providers/saml2/admin.py @@ -157,6 +157,9 @@ class SPAdminPage(AdminPage): value = kwargs[name] if isinstance(option, pconfig.List): value = [x.strip() for x in value.split('\n')] + # for normal lists we want unordered comparison + if set(value) == set(option.get_value()): + continue elif isinstance(option, pconfig.Condition): value = True else: @@ -168,9 +171,9 @@ class SPAdminPage(AdminPage): aname = '%s_%s' % (name, a) if aname in kwargs: value.append(a) - elif type(option) is pconfig.ComplexList: + elif isinstance(option, pconfig.MappingList): current = deepcopy(option.get_value()) - value = get_complex_list_value(name, + value = get_mapping_list_value(name, current, **kwargs) # if current value is None do nothing @@ -178,9 +181,9 @@ class SPAdminPage(AdminPage): if option.get_value() is None: continue # else pass and let it continue as None - elif type(option) is pconfig.MappingList: + elif isinstance(option, pconfig.ComplexList): current = deepcopy(option.get_value()) - value = get_mapping_list_value(name, + value = get_complex_list_value(name, current, **kwargs) # if current value is None do nothing @@ -192,9 +195,6 @@ class SPAdminPage(AdminPage): continue if value != option.get_value(): - if (type(option) is pconfig.List and - set(value) == set(option.get_value())): - continue cherrypy.log.error("Storing %s = %s" % (name, value), severity=logging.DEBUG) new_db_values[name] = value diff --git a/ipsilon/providers/saml2/auth.py b/ipsilon/providers/saml2/auth.py index 8b84bc2..9d2bb7d 100644 --- a/ipsilon/providers/saml2/auth.py +++ b/ipsilon/providers/saml2/auth.py @@ -316,7 +316,6 @@ class AuthenticateRequest(ProviderPageBase): ], "submit": 'Return to application', } - # pylint: disable=star-args return self._template('saml2/post_response.html', **context) else: diff --git a/ipsilon/providers/saml2/provider.py b/ipsilon/providers/saml2/provider.py index 5d36fbd..75bfc1d 100644 --- a/ipsilon/providers/saml2/provider.py +++ b/ipsilon/providers/saml2/provider.py @@ -133,7 +133,7 @@ class ServiceProvider(ServiceProviderConfig): @allowed_nameids.setter def allowed_nameids(self, value): - if type(value) is not list: + if not isinstance(value, list): raise ValueError("Must be a list") self._staging['allowed nameids'] = ','.join(value) -- cgit