diff --git a/apiserver/utilities/parameter_key_escaper.py b/apiserver/utilities/parameter_key_escaper.py index 759bb64..c08bc80 100644 --- a/apiserver/utilities/parameter_key_escaper.py +++ b/apiserver/utilities/parameter_key_escaper.py @@ -1,7 +1,5 @@ from boltons.dictutils import OneToOne -from apiserver.apierrors import errors - class ParameterKeyEscaper: """ @@ -14,11 +12,8 @@ class ParameterKeyEscaper: _mapping = OneToOne({".": "%2E", "$": "%24", "__": "%_%_"}) @classmethod - def escape(cls, value): + def escape(cls, value: str): """ Quote a parameter key """ - if value is None: - raise errors.bad_request.ValidationError("Key cannot be empty") - value = value.strip().replace("%", "%%") for c, r in cls._mapping.items(): @@ -30,13 +25,13 @@ class ParameterKeyEscaper: return value @classmethod - def _unescape(cls, value): + def _unescape(cls, value: str): for c, r in cls._mapping.inv.items(): value = value.replace(c, r) return value @classmethod - def unescape(cls, value): + def unescape(cls, value: str): """ Unquote a quoted parameter key """ value = "%".join(map(cls._unescape, value.split("%%"))) diff --git a/apiserver/utilities/threads_manager.py b/apiserver/utilities/threads_manager.py index 1c5f604..a9b052b 100644 --- a/apiserver/utilities/threads_manager.py +++ b/apiserver/utilities/threads_manager.py @@ -1,15 +1,15 @@ from functools import wraps from threading import Lock, Thread -from typing import ClassVar +from typing import ClassVar, Callable class ThreadsManager: objects = {} lock = Lock() + request_context_creator: ClassVar[Callable] = None terminating: ClassVar[bool] = False def __init__(self, name=None, **threads): - super(ThreadsManager, self).__init__() self.name = name or self.__class__.__name__ self.objects = {} self.lock = Lock()