From 15dc7a821bffc1ecaff4a350a03f753004a0139b Mon Sep 17 00:00:00 2001 From: Federated Secure Computing Date: Tue, 5 Mar 2024 21:51:46 +0100 Subject: [PATCH] improve pylint --- src/federatedsecure/server/bus.py | 23 +++++++++++++++-------- src/federatedsecure/server/discovery.py | 8 +++++--- src/federatedsecure/server/exceptions.py | 6 ++++-- src/federatedsecure/server/registry.py | 9 ++++++--- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/federatedsecure/server/bus.py b/src/federatedsecure/server/bus.py index c394609..d76bcb9 100644 --- a/src/federatedsecure/server/bus.py +++ b/src/federatedsecure/server/bus.py @@ -7,7 +7,8 @@ class Bus: - """the bus stores representations of microservices and other server-side objects""" + """the bus stores representations of + microservices and other server-side objects""" def __init__(self): """initialize the bus""" @@ -18,7 +19,8 @@ def get_argument(self, arg): if isinstance(arg, dict): if 'representation_uuid' in arg: if arg['representation_uuid'] in self.lut_uuid_to_repr: - return self.get_argument(self.lut_uuid_to_repr[arg['representation_uuid']]) + return self.get_argument( + self.lut_uuid_to_repr[arg['representation_uuid']]) return arg def get_arguments(self, body): @@ -72,22 +74,27 @@ def release_representation(self, representation_uuid): """release a representation""" del self.lut_uuid_to_repr[representation_uuid] - def create_attribute(self, representation_uuid, attribute_name, public=False): + def create_attribute(self, representation_uuid, + attribute_name, public=False): """create a representation of an attribute of a representation""" - if public and attribute_name[0] == '_': # public access to private/hidden member - raise federatedsecure.server.exceptions.AttributeNotPublic(attribute_name) + # public access to private/hidden member + if public and attribute_name[0] == '_': + raise federatedsecure.server.exceptions.\ + AttributeNotPublic(attribute_name) try: obj = self.lut_uuid_to_repr[representation_uuid] except KeyError as key_error: - raise federatedsecure.server.exceptions.InvalidIdentifier("representation_uuid", - representation_uuid) from key_error + raise federatedsecure.server.exceptions.\ + InvalidIdentifier("representation_uuid", + representation_uuid) from key_error try: pointer = getattr(obj, attribute_name) except KeyError as key_error: - raise federatedsecure.server.exceptions.AttributeNotFound(attribute_name) from key_error + raise federatedsecure.server.exceptions.\ + AttributeNotFound(attribute_name) from key_error uuid = str(_uuid.uuid4()) self.lut_uuid_to_repr[uuid] = pointer diff --git a/src/federatedsecure/server/discovery.py b/src/federatedsecure/server/discovery.py index 2c99c0b..eb32b28 100644 --- a/src/federatedsecure/server/discovery.py +++ b/src/federatedsecure/server/discovery.py @@ -7,11 +7,13 @@ def discover_builtins_and_plugins(registry): - """discover microservices and classes in federatedsecure.server.services and federatedsecure.server.services""" + """discover microservices and classes in federatedsecure.server.services + and federatedsecure.server.services""" for namespace_package in [federatedsecure.services]: - for _, name, _ in pkgutil.iter_modules(namespace_package.__path__, - namespace_package.__name__ + "."): + for _, name, _ in pkgutil.iter_modules( + namespace_package.__path__, + namespace_package.__name__ + "."): module = importlib.import_module(name) try: getattr(module, "federatedsecure_register")(registry) diff --git a/src/federatedsecure/server/exceptions.py b/src/federatedsecure/server/exceptions.py index 3828291..9860b79 100644 --- a/src/federatedsecure/server/exceptions.py +++ b/src/federatedsecure/server/exceptions.py @@ -71,14 +71,16 @@ def __init__(self, missing): class AttributeNotFound(ApiError): - """this exception is thrown when a member attribute of an object does not exist""" + """this exception is thrown when a member + attribute of an object does not exist""" def __init__(self, missing): super().__init__(404, f'attribute not available: {missing}') class AttributeNotPublic(ApiError): - """this exception is thrown when a hidden/private member attribute of an object is accessed""" + """this exception is thrown when a hidden/private + member attribute of an object is accessed""" def __init__(self, missing): super().__init__(403, f'attribute not public: {missing}') diff --git a/src/federatedsecure/server/registry.py b/src/federatedsecure/server/registry.py index 9b5401c..a396786 100644 --- a/src/federatedsecure/server/registry.py +++ b/src/federatedsecure/server/registry.py @@ -1,4 +1,5 @@ -"""the registry contains items that may be used as root items for representations""" +"""the registry contains items that may +be used as root items for representations""" import uuid as _uuid @@ -28,7 +29,8 @@ def list_representations(self): return result def get_representation(self, requirements): - """check requirements against descriptions and return a matching item if possible""" + """check requirements against descriptions + and return a matching item if possible""" for uuid, (description, item) in self.root_objects.items(): for requirement in requirements: @@ -39,4 +41,5 @@ def get_representation(self, requirements): else: return uuid, item - raise federatedsecure.server.exceptions.RootObjectNotFound(requirements) + raise federatedsecure.server.exceptions.\ + RootObjectNotFound(requirements)