From e1abfe0fb7079f47c63e65048b1a54fa32fe258a Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 11 Jun 2021 08:43:23 +0200 Subject: [PATCH] Fix Custodia pylint issues See: https://pagure.io/freeipa/issue/8882 Signed-off-by: Christian Heimes Reviewed-By: Alexander Bokovoy Reviewed-By: Rob Crittenden --- ipaserver/custodia/client.py | 2 +- ipaserver/custodia/httpd/authorizers.py | 2 +- ipaserver/custodia/httpd/server.py | 2 +- ipaserver/custodia/log.py | 2 +- ipaserver/custodia/message/common.py | 2 +- ipaserver/custodia/message/formats.py | 2 +- ipaserver/custodia/message/kem.py | 2 +- ipaserver/custodia/plugin.py | 12 ++++++------ ipaserver/custodia/secrets.py | 3 +-- ipaserver/custodia/server/config.py | 4 ++-- 10 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ipaserver/custodia/client.py b/ipaserver/custodia/client.py index 7b676eda3..a40e9ed7e 100644 --- a/ipaserver/custodia/client.py +++ b/ipaserver/custodia/client.py @@ -62,7 +62,7 @@ class HTTPUnixAdapter(HTTPAdapter): DEFAULT_HEADERS = {'Content-Type': 'application/json'} -class CustodiaHTTPClient(object): +class CustodiaHTTPClient: timeout = None # seconds (float) def __init__(self, url): diff --git a/ipaserver/custodia/httpd/authorizers.py b/ipaserver/custodia/httpd/authorizers.py index 83e1c4af8..64638163e 100644 --- a/ipaserver/custodia/httpd/authorizers.py +++ b/ipaserver/custodia/httpd/authorizers.py @@ -42,7 +42,7 @@ class SimplePathAuthz(HTTPAuthorizer): if path == '/': path = '' else: - path, _ = os.path.split(path) + path, _head = os.path.split(path) self.logger.debug('No path in %s matched %s', self.paths, reqpath) return None diff --git a/ipaserver/custodia/httpd/server.py b/ipaserver/custodia/httpd/server.py index 9c34f46f7..235773249 100644 --- a/ipaserver/custodia/httpd/server.py +++ b/ipaserver/custodia/httpd/server.py @@ -492,7 +492,7 @@ class HTTPRequestHandler(BaseHTTPRequestHandler): raise HTTPError(404) -class HTTPServer(object): +class HTTPServer: handler = HTTPRequestHandler def __init__(self, srvurl, config): diff --git a/ipaserver/custodia/log.py b/ipaserver/custodia/log.py index 9efe2b2ac..3e814069f 100644 --- a/ipaserver/custodia/log.py +++ b/ipaserver/custodia/log.py @@ -158,7 +158,7 @@ AUDIT_MESSAGES = [ ] -class AuditLog(object): +class AuditLog: def __init__(self, logger): self.logger = logger diff --git a/ipaserver/custodia/message/common.py b/ipaserver/custodia/message/common.py index 18b4c78eb..d63690f8a 100644 --- a/ipaserver/custodia/message/common.py +++ b/ipaserver/custodia/message/common.py @@ -39,7 +39,7 @@ class UnallowedMessage(Exception): super(UnallowedMessage, self).__init__(message) -class MessageHandler(object): +class MessageHandler: def __init__(self, request): self.req = request diff --git a/ipaserver/custodia/message/formats.py b/ipaserver/custodia/message/formats.py index 0dca2e9be..caa287286 100644 --- a/ipaserver/custodia/message/formats.py +++ b/ipaserver/custodia/message/formats.py @@ -14,7 +14,7 @@ key_types = {'simple': SimpleKey, 'kem': KEMHandler} -class Validator(object): +class Validator: """Validates incoming messages.""" def __init__(self, allowed=None): diff --git a/ipaserver/custodia/message/kem.py b/ipaserver/custodia/message/kem.py index b7eecd5e4..fbbc3fe46 100644 --- a/ipaserver/custodia/message/kem.py +++ b/ipaserver/custodia/message/kem.py @@ -200,7 +200,7 @@ class KEMHandler(MessageHandler): return {'type': 'kem', 'value': value} -class KEMClient(object): +class KEMClient: def __init__(self, server_keys, client_keys): self.server_keys = server_keys diff --git a/ipaserver/custodia/plugin.py b/ipaserver/custodia/plugin.py index feb0979ea..08659e172 100644 --- a/ipaserver/custodia/plugin.py +++ b/ipaserver/custodia/plugin.py @@ -20,14 +20,14 @@ from .log import CustodiaLoggingAdapter, auditlog, getLogger logger = getLogger(__name__) -class _Required(object): +class _Required: __slots__ = () def __repr__(self): return 'REQUIRED' -class INHERIT_GLOBAL(object): # noqa: N801 +class INHERIT_GLOBAL: # noqa: N801 __slots__ = ('default',) def __init__(self, default): @@ -68,7 +68,7 @@ class CSStoreDenied(CustodiaException): pass -class OptionHandler(object): +class OptionHandler: """Handler and parser for plugin options """ def __init__(self, parser, section): @@ -108,7 +108,7 @@ class OptionHandler(object): def check_surplus(self): surplus = [] - for name, _ in self.parser.items(self.section): + for name, _value in self.parser.items(self.section): if (name not in self.seen and not self.parser.has_option(configparser.DEFAULTSECT, name)): surplus.append(name) @@ -190,7 +190,7 @@ class OptionHandler(object): return json.loads(value) -class PluginOption(object): +class PluginOption: """Plugin option code:: @@ -293,7 +293,7 @@ class CustodiaPluginMeta(abc.ABCMeta): @six.add_metaclass(CustodiaPluginMeta) -class CustodiaPlugin(object): +class CustodiaPlugin: """Abstract base class for all Custodia plugins """ _options = () diff --git a/ipaserver/custodia/secrets.py b/ipaserver/custodia/secrets.py index c3b123686..01f805b23 100644 --- a/ipaserver/custodia/secrets.py +++ b/ipaserver/custodia/secrets.py @@ -114,10 +114,9 @@ class Secrets(HTTPConsumer): for t in types: if t.strip() == 'application/json': binary = False - break elif t.strip() == 'application/octet-stream': binary = True - if binary is True: + if binary: response['headers'][ 'Content-Type'] = 'application/octet-stream' response['output'] = b64decode(reply['value']) diff --git a/ipaserver/custodia/server/config.py b/ipaserver/custodia/server/config.py index f9172215e..e8663dce9 100644 --- a/ipaserver/custodia/server/config.py +++ b/ipaserver/custodia/server/config.py @@ -11,7 +11,7 @@ from ipaserver.custodia.compat import configparser from ipaserver.custodia.compat import url_escape -class CustodiaConfig(object): +class CustodiaConfig: CONFIG_SPECIALS = ['authenticators', 'authorizers', 'consumers', 'stores'] DEFAULT_PATHS = [ @@ -86,7 +86,7 @@ class CustodiaConfig(object): return configfiles def makedirs(self): - for name, _ in self.DEFAULT_PATHS: + for name, _path in self.DEFAULT_PATHS: path = self.parser.get(u'DEFAULT', name) parent = os.path.dirname(path) # create parents according to umask