diff --git a/satella/coding/call_hierarchy.py b/satella/coding/call_hierarchy.py index ba642ccdaab64a87807a0b1f2ef7c0ea3b4bab06..6d9d91e8e8b430d4c1d9697e4db89407ba11a906 100644 --- a/satella/coding/call_hierarchy.py +++ b/satella/coding/call_hierarchy.py @@ -15,7 +15,7 @@ __all__ = ['Call', 'CallIf', 'CallWithArgumentSet', 'ExecutionEnvironment', 'cal def push_call_stack(cs: tp.Callable, args: tuple = (), kwargs: tp.Optional[dict] = None) -> None: kwargs = kwargs or {} - arg_tuple = ((cs, args, kwargs), ) + arg_tuple = ((cs, args, kwargs),) if not hasattr(local_ee, 'cs'): local_ee.cs = arg_tuple else: diff --git a/satella/coding/concurrent/id_allocator.py b/satella/coding/concurrent/id_allocator.py index 6750a67a0173e5d8a5eebd5faec84f32ef611908..c3b974bad03438f6a0eb70a482b3207a4d73d617 100644 --- a/satella/coding/concurrent/id_allocator.py +++ b/satella/coding/concurrent/id_allocator.py @@ -10,7 +10,7 @@ class SequentialIssuer(Monitor): :ivar start: next value to be issued """ - __slots__ = ('start', ) + __slots__ = ('start',) def __init__(self, start: int = 0): super().__init__() diff --git a/satella/coding/concurrent/queue.py b/satella/coding/concurrent/queue.py index c03e2d30a7d8b8a27ea5a74132e0e51476a0991e..e3f8aa66d724cb1cb013e2025d6e9856bb6fc3d4 100644 --- a/satella/coding/concurrent/queue.py +++ b/satella/coding/concurrent/queue.py @@ -97,4 +97,3 @@ class PeekableQueue(tp.Generic[T]): :return: approximate size of the queue """ return len(self.queue) - diff --git a/satella/coding/concurrent/thread.py b/satella/coding/concurrent/thread.py index 33440f4f6b776d8b4322e9bdfca60ae02cb5afda..4ad78f12a00e47ccbef9926099411d6b8f0c4da5 100644 --- a/satella/coding/concurrent/thread.py +++ b/satella/coding/concurrent/thread.py @@ -242,7 +242,7 @@ class TerminableThread(threading.Thread): super().__init__(*args, **kwargs) self._terminating = False # type: bool if terminate_on is None: - terminate_on = (SystemExit, ) + terminate_on = (SystemExit,) elif isinstance(terminate_on, tuple): terminate_on = (SystemExit, *terminate_on) else: @@ -338,7 +338,7 @@ class TerminableThread(threading.Thread): while t < timeout: if self._terminating: raise SystemExit() - ttw = min(timeout-t, wake_up_each) + ttw = min(timeout - t, wake_up_each) t += ttw try: condition.wait(ttw) diff --git a/satella/coding/concurrent/timer.py b/satella/coding/concurrent/timer.py index de0ea0f535d8d7d85cc4449a01bc0ce9921a7733..25aeab933a45d2deff0ca0a4e9d517df74f4291f 100644 --- a/satella/coding/concurrent/timer.py +++ b/satella/coding/concurrent/timer.py @@ -32,7 +32,8 @@ class Timer: __slots__ = ('args', 'kwargs', 'spawn_separate', 'interval', 'function', 'execute_at', 'cancelled') - def __init__(self, interval: tp.Union[str, float], function, args=None, kwargs=None, spawn_separate=False): + def __init__(self, interval: tp.Union[str, float], function, args=None, kwargs=None, + spawn_separate=False): self.args = args or [] self.kwargs = kwargs or {} self.spawn_separate = spawn_separate diff --git a/satella/coding/decorators/arguments.py b/satella/coding/decorators/arguments.py index 4591b4fa2eaa6e56dbf68e70742716af629bbef2..e415ed5bbf252e186ba0e3690b075971187e50a4 100644 --- a/satella/coding/decorators/arguments.py +++ b/satella/coding/decorators/arguments.py @@ -30,6 +30,7 @@ def transform_result(expr: str): :param expr: Python string expression """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): @@ -37,7 +38,9 @@ def transform_result(expr: str): local = get_arguments(fun, *args, *kwargs) local['x'] = a return eval(expr, globals(), local) + return inner + return outer @@ -55,6 +58,7 @@ def transform_arguments(**expressions: str): :param expressions: Python strings that are meant to be evaluated """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): @@ -66,7 +70,9 @@ def transform_arguments(**expressions: str): if new_arg not in new_args: new_args[new_arg] = old_args[new_arg] return call_with_arguments(fun, new_args) + return inner + return outer diff --git a/satella/coding/decorators/decorators.py b/satella/coding/decorators/decorators.py index 702c234983758b8a50e03a8f03cf34132179597d..8173c6226fd8e179d1b07b6c86a2cd8844e4b72e 100644 --- a/satella/coding/decorators/decorators.py +++ b/satella/coding/decorators/decorators.py @@ -85,6 +85,7 @@ def default_return(v: tp.Any): :param v: value to return if calling the function would return None """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): @@ -93,7 +94,9 @@ def default_return(v: tp.Any): return v else: return v_a + return inner + return outer @@ -118,6 +121,7 @@ def return_as_list(ignore_nulls: bool = False): :param ignore_nulls: if True, then if your function yields None, it won't be appended. """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): @@ -127,7 +131,9 @@ def return_as_list(ignore_nulls: bool = False): continue output.append(item) return output + return inner + return outer @@ -177,6 +183,7 @@ def cache_memoize(cache_duration: float, time_getter: tp.Callable[[], float] = t return fun.memoize_values[args] return inner + return outer diff --git a/satella/coding/decorators/preconditions.py b/satella/coding/decorators/preconditions.py index fe6557fc291f1460f71049b757be0ead4a94924e..ae6e55fe753266b21fb9732e5b5827b6e3794ec8 100644 --- a/satella/coding/decorators/preconditions.py +++ b/satella/coding/decorators/preconditions.py @@ -100,6 +100,7 @@ def postcondition(condition: Condition): :param condition: callable that accepts a single argument, the return value of the function. Can be also a string, in which case it is an expression about the value x of return """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): diff --git a/satella/coding/decorators/retry_dec.py b/satella/coding/decorators/retry_dec.py index 098626d1036df2bda6321bc06e3ba502643e0ec7..fdafd6458e5f174e433c3dc9efc3353d9d1d3d87 100644 --- a/satella/coding/decorators/retry_dec.py +++ b/satella/coding/decorators/retry_dec.py @@ -45,6 +45,7 @@ def retry(times: tp.Optional[int] = None, instance that forced the retry. :return: function result """ + def outer(fun): @wraps(fun) def inner(*args, **kwargs): @@ -69,5 +70,7 @@ def retry(times: tp.Optional[int] = None, call_on_failure(f) if not swallow_exception: raise f + return inner + return outer diff --git a/satella/coding/misc.py b/satella/coding/misc.py index 1f3ff3f53f320875c91bd83f5d9e0114127e2629..e6277795fc0bb12e4aad41bbec7c55428fb70f34 100644 --- a/satella/coding/misc.py +++ b/satella/coding/misc.py @@ -61,7 +61,7 @@ class Closeable: You should extend both __init__ and close() """ - __slots__ = ('__finalized', ) + __slots__ = ('__finalized',) def __init__(self): self.__finalized = False @@ -135,6 +135,7 @@ def chain_callables(callable1: tp.Callable, callable2: tp.Callable) -> tp.Callab :param callable2: callable to call with callable1's result :return: result of callable2 """ + def inner(*args, **kwargs): res = callable1(*args, **kwargs) try: @@ -146,6 +147,7 @@ def chain_callables(callable1: tp.Callable, callable2: tp.Callable) -> tp.Callab else: raise return res + return inner @@ -305,7 +307,7 @@ def _get_arguments(function: tp.Callable, special_behaviour: bool, *args, **kwar else: v = keyword.default except (AttributeError, TypeError): - continue # comparison was impossible + continue # comparison was impossible local_vars[keyword_name] = v diff --git a/satella/coding/optionals.py b/satella/coding/optionals.py index 3121eb18cee23f5ca34038dd300d400b5630769e..00be5883369f3962474c4926380aafc52aee9677 100644 --- a/satella/coding/optionals.py +++ b/satella/coding/optionals.py @@ -63,6 +63,7 @@ class Optional(Proxy[T]): :param obj: object to wrap """ + def __init__(self, obj): super().__init__(obj) diff --git a/satella/coding/sequences/iterators.py b/satella/coding/sequences/iterators.py index 7c4f598fa7a57032e5ff81d5864cb588e725d800..f3800cdb5dbe9a0d843e74deca33250d15f46c9f 100644 --- a/satella/coding/sequences/iterators.py +++ b/satella/coding/sequences/iterators.py @@ -220,7 +220,7 @@ class AlreadySeen(tp.Generic[K]): __slots__ = ('set',) def __init__(self): - self.set = None # type: tp.Union[list, set] + self.set = None # type: tp.Union[list, set] def is_unique(self, key: K) -> bool: """ diff --git a/satella/coding/structures/dictionaries/cache_dict.py b/satella/coding/structures/dictionaries/cache_dict.py index 799781dc4bd80889dee7013d5c9fe8e01d5f6abc..8536fe0944bdc7197f73676426781cdc3fd38a92 100644 --- a/satella/coding/structures/dictionaries/cache_dict.py +++ b/satella/coding/structures/dictionaries/cache_dict.py @@ -43,6 +43,7 @@ class CacheDict(tp.Mapping[K, V]): that will be given to user instead of throwing KeyError. If not given (default), KeyError will be thrown """ + def __len__(self) -> int: return len(self.data) @@ -226,7 +227,7 @@ class LRUCacheDict(CacheDict[K, V]): """ Assure that there's place for at least one element """ - while len(self) > self.max_size-1: + while len(self) > self.max_size - 1: self.evict() @silence_excs(KeyError) diff --git a/satella/coding/structures/dictionaries/default.py b/satella/coding/structures/dictionaries/default.py index fa6d9a68b45cee35e080e91ec8b82bb2e2ca9176..f0035025725353c8c4d42e3d594b7ec1bccd258c 100644 --- a/satella/coding/structures/dictionaries/default.py +++ b/satella/coding/structures/dictionaries/default.py @@ -5,6 +5,7 @@ class DefaultDict(collections.defaultdict): """ A collections.defaultdict that does not store in itself empty values that it generates """ + def __getitem__(self, item): if item not in self: return self.default_factory() diff --git a/satella/coding/structures/mixins/enums.py b/satella/coding/structures/mixins/enums.py index 39b761369abdb96d98e09779b7ceede3d8422684..7dd5f95f64b411d8e3cff504ada7be5eeb1ac96d 100644 --- a/satella/coding/structures/mixins/enums.py +++ b/satella/coding/structures/mixins/enums.py @@ -36,7 +36,7 @@ class ComparableEnum(enum.Enum): if not isinstance(other, self.__class__): try: return self.__class__(other) == self - except ValueError: # other is not a correct member of this class! + except ValueError: # other is not a correct member of this class! return False else: return super().__eq__(other) diff --git a/satella/coding/structures/push_iterable.py b/satella/coding/structures/push_iterable.py index 4daad6ef7f2f47df979b6b5975240ba3f369aa21..e0a6fc3fffe2fc64ba387bca3292fca7b88d5711 100644 --- a/satella/coding/structures/push_iterable.py +++ b/satella/coding/structures/push_iterable.py @@ -29,6 +29,7 @@ class PushIterable(tp.Generic[T]): assert a.pop() == 3 assertRaises(StopIteration, a.pop) """ + def __init__(self, iterable: tp.Iterable[T]): self.iterable = iter(iterable) self.collection = deque() diff --git a/satella/coding/structures/syncable_droppable.py b/satella/coding/structures/syncable_droppable.py index ed6dd3488058c519ba3ab6ee08307d7714a7057d..4c40df745e6fd15f30e5bd4b2c2f515dbe2c95b7 100644 --- a/satella/coding/structures/syncable_droppable.py +++ b/satella/coding/structures/syncable_droppable.py @@ -114,13 +114,13 @@ class SyncableDroppable(RMonitor, tp.Generic[K, V]): super().__init__() assert span_to_keep_in_memory and span_to_keep_in_db, 'One of spans was false!' assert span_to_keep_in_db > span_to_keep_in_memory, 'Invalid span' - self.db_storage = db_storage # type: DBStorage - self._start_entry = start_entry # type: K - self._stop_entry = stop_entry # type: K - self._synced_up_to = synced_up_to # type: K - self.data_in_memory = [] # type: tp.List[KVTuple] - self.span_to_keep_in_db = span_to_keep_in_db # type: K - self.span_to_keep_in_memory = span_to_keep_in_memory # type: K + self.db_storage = db_storage # type: DBStorage + self._start_entry = start_entry # type: K + self._stop_entry = stop_entry # type: K + self._synced_up_to = synced_up_to # type: K + self.data_in_memory = [] # type: tp.List[KVTuple] + self.span_to_keep_in_db = span_to_keep_in_db # type: K + self.span_to_keep_in_memory = span_to_keep_in_memory # type: K @property def start_entry(self) -> tp.Optional[K]: @@ -349,7 +349,7 @@ class SyncableDroppable(RMonitor, tp.Generic[K, V]): if maximum_entries == math.inf: return self.data_in_memory[index:] else: - return self.data_in_memory[index:index+maximum_entries] + return self.data_in_memory[index:index + maximum_entries] else: # We have to start off the disk data = [] diff --git a/satella/coding/structures/tuples.py b/satella/coding/structures/tuples.py index 9eb8a589acfddaa31098fc2520acf0ab02338993..98da0c7268275689bd73cb205d67dd10d3aef4b3 100644 --- a/satella/coding/structures/tuples.py +++ b/satella/coding/structures/tuples.py @@ -32,13 +32,13 @@ class Vector(tuple): def __mul__(self, other: Number) -> 'Vector': result = [] for a in self: - result.append(a*other) + result.append(a * other) return Vector(result) def __truediv__(self, other: Number) -> 'Vector': result = [] for a in self: - result.append(a/other) + result.append(a / other) return Vector(result) __imul__ = __mul__ diff --git a/satella/coding/transforms/interpol.py b/satella/coding/transforms/interpol.py index fc817a12a22c674d7a090c68d8e8e84a788693e2..ab80ecbf38eb6ec93044d7230564f4d67cf43dd9 100644 --- a/satella/coding/transforms/interpol.py +++ b/satella/coding/transforms/interpol.py @@ -35,11 +35,11 @@ def linear_interpolate(series: tp.Sequence[tp.Tuple[K, U]], t: K, i = bisect.bisect_left([y[0] for y in series], t) - 1 - if i == len(series)-1: + if i == len(series) - 1: return series[-1][1] t1, v1 = series[i] - t2, v2 = series[i+1] + t2, v2 = series[i + 1] assert t1 <= t <= t2, 'Series not sorted!' return (v2 - v1) / (t2 - t1) * (t - t1) + v1 diff --git a/satella/coding/transforms/merge_list.py b/satella/coding/transforms/merge_list.py index 6b3aa8ba7dc1485e6d523317d8abd2bf77705187..99a03839c8f6763a8707d001f5b58898c8ac8337 100644 --- a/satella/coding/transforms/merge_list.py +++ b/satella/coding/transforms/merge_list.py @@ -72,4 +72,3 @@ class merge_list(tp.Iterator[tp.Tuple[K, V]]): except StopIteration: self.available_lists.remove(i) return k, v, i - diff --git a/satella/coding/typing.py b/satella/coding/typing.py index 68a94fa07e740b24b7372d9d1adc3786fc46ab44..8b79d2cf82a7d3a8df245bb2f41105bf8551febf 100644 --- a/satella/coding/typing.py +++ b/satella/coding/typing.py @@ -5,7 +5,6 @@ __all__ = ['Iteratable', 'T', 'U', 'V', 'K', 'Number', 'ExceptionClassType', 'NoArgCallable', 'Appendable', 'Predicate', 'KVTuple', 'Comparable', 'ExceptionList', 'NoneType'] - NoneType = None.__class__ T = tp.TypeVar('T') Iteratable = tp.Union[tp.Iterator[T], tp.Iterable[T]] @@ -46,5 +45,3 @@ except ImportError: class Appendable(Protocol[T]): def append(self, item: T) -> None: ... - - diff --git a/satella/configuration/schema/__init__.py b/satella/configuration/schema/__init__.py index e13557041874bcf75d8f42937edb54ca63873e93..3e87cdbc2356aef4e2ba352275112754875c8215 100644 --- a/satella/configuration/schema/__init__.py +++ b/satella/configuration/schema/__init__.py @@ -1,5 +1,6 @@ from .base import CheckerCondition, Descriptor -from .basic import IPv4, Integer, String, Float, Boolean, File, Directory, FileObject, DirectoryObject +from .basic import IPv4, Integer, String, Float, Boolean, File, Directory, FileObject, \ + DirectoryObject from .from_json import descriptor_from_dict from .registry import register_custom_descriptor from .structs import Union, List, Dict, Caster, create_key diff --git a/satella/configuration/schema/basic.py b/satella/configuration/schema/basic.py index 03464e8a93da95961f0ff70b893e9293b3c08837..f451d800559ebdde5b088813a307f19c504d1dae 100644 --- a/satella/configuration/schema/basic.py +++ b/satella/configuration/schema/basic.py @@ -66,7 +66,7 @@ class FileObject: self.path = path def __repr__(self): - return '<File object %s>' % (self.path, ) + return '<File object %s>' % (self.path,) def __str__(self): return self.path @@ -113,7 +113,7 @@ class DirectoryObject: self.path = path def __repr__(self): - return '<Directory object %s>' % (self.path, ) + return '<Directory object %s>' % (self.path,) def __str__(self): return self.path @@ -134,7 +134,6 @@ class DirectoryObject: @staticmethod def _make_file(v: str) -> bool: - if not os.path.isfile(v): raise ConfigurationValidationError('Expected to find a file under %s' % (v,)) @@ -178,7 +177,6 @@ class FileContents(Descriptor): @staticmethod def _make_directory(v: str) -> bool: - if not os.path.isdir(v): raise ConfigurationValidationError('Expected to find a directory under %s' % (v,)) diff --git a/satella/configuration/sources/from_dict.py b/satella/configuration/sources/from_dict.py index ecfe8cf75c18a5c0dc3f69de1145af76d8c450a3..8300a42f10c922de4bbbcc43d3030744462eab59 100644 --- a/satella/configuration/sources/from_dict.py +++ b/satella/configuration/sources/from_dict.py @@ -74,7 +74,7 @@ def load_source_from_dict(dct: dict) -> BaseSource: try: s = sources.__dict__[type_](*args, **kwargs) except KeyError as e: - raise ConfigurationMisconfiguredError('unknown type %s' % (type_, )) + raise ConfigurationMisconfiguredError('unknown type %s' % (type_,)) if optional: s = sources.OptionalSource(s) diff --git a/satella/configuration/sources/object_from.py b/satella/configuration/sources/object_from.py index e780a2849d79a63cd77179be023a38fdb5f36ef2..1bfc49820e9d6a22f507cac6e87918a97951d6c6 100644 --- a/satella/configuration/sources/object_from.py +++ b/satella/configuration/sources/object_from.py @@ -1,6 +1,5 @@ from .base import BaseSource - __all__ = ['BuildObjectFrom'] diff --git a/satella/exception_handling/dump_to_file.py b/satella/exception_handling/dump_to_file.py index 2a958c92f2c3df3560ea01eeecd9a2d506686da0..de294049c7359f683a584b7b1b93ce70951a1697 100644 --- a/satella/exception_handling/dump_to_file.py +++ b/satella/exception_handling/dump_to_file.py @@ -21,7 +21,7 @@ class StreamType(enum.IntEnum): MODE_FILE = 0 # write to file MODE_STREAM = 1 # a file-like object was provided MODE_DEVNULL = 2 # just redirect to /dev/null - MODE_LOGGER = 3 # just a logger + MODE_LOGGER = 3 # just a logger class AsStream: diff --git a/satella/instrumentation/cpu_time/collector.py b/satella/instrumentation/cpu_time/collector.py index e34133076fd0f35d00ef72927eea2aef7f8cf0eb..f5e820befba91829e392313975e928778e5034f2 100644 --- a/satella/instrumentation/cpu_time/collector.py +++ b/satella/instrumentation/cpu_time/collector.py @@ -25,9 +25,10 @@ class CPUProfileBuilderThread(threading.Thread): Or a time string. :param refresh_each: time of seconds to sleep between rebuilding of profiles, or a time string. """ + def __init__(self, window_seconds: tp.Union[str, int] = DEFAULT_WINDOW_SECONDS, refresh_each: tp.Union[str, int] = DEFAULT_REFRESH_EACH, - percentiles_requested: tp.Sequence[float] = (0.9, )): + percentiles_requested: tp.Sequence[float] = (0.9,)): super().__init__(name='CPU profile builder', daemon=True) self.window_size = int(parse_time_string(window_seconds)) self.refresh_each = parse_time_string(refresh_each) @@ -55,7 +56,7 @@ class CPUProfileBuilderThread(threading.Thread): def recalculate(self) -> None: data = [] - calculate_occupancy_factor() # as first values tend to be a bit wonky + calculate_occupancy_factor() # as first values tend to be a bit wonky for _ in range(int(self.window_size)): time.sleep(1) data.append(calculate_occupancy_factor()) @@ -110,7 +111,7 @@ def sleep_cpu_aware(seconds: tp.Union[str, float], of_below: tp.Optional[float] if of_below is None and of_above is None: time.sleep(seconds) return False - calculate_occupancy_factor() # prime the counter + calculate_occupancy_factor() # prime the counter while seconds > 0: time_to_sleep = min(seconds, check_each) time.sleep(time_to_sleep) @@ -128,8 +129,8 @@ def sleep_cpu_aware(seconds: tp.Union[str, float], of_below: tp.Optional[float] return False -previous_cf = None # type: float -previous_timestamp = None # type: float +previous_cf = None # type: float +previous_timestamp = None # type: float def _calculate_occupancy_factor() -> float: @@ -157,7 +158,7 @@ def _calculate_occupancy_factor() -> float: delta = cur_time - previous_timestamp if delta == 0: return - of = (occupation_factor - previous_cf)/delta + of = (occupation_factor - previous_cf) / delta previous_cf = occupation_factor previous_timestamp = cur_time return of @@ -180,4 +181,3 @@ def calculate_occupancy_factor() -> float: time.sleep(0.1) c = _calculate_occupancy_factor() return c - diff --git a/satella/instrumentation/cpu_time/concurrency.py b/satella/instrumentation/cpu_time/concurrency.py index 177871a79ac89e7507c8737704a6f67883b7fd34..26f7438cafa601a1bbfff4eead6a18de91942ce8 100644 --- a/satella/instrumentation/cpu_time/concurrency.py +++ b/satella/instrumentation/cpu_time/concurrency.py @@ -22,7 +22,8 @@ class CPUTimeAwareIntervalTerminableThread(IntervalTerminableThread, metaclass=A Can be also a time string """ - def __init__(self, seconds: tp.Union[str, float], max_sooner: tp.Optional[float] = None, percentile: float = 0.3, + def __init__(self, seconds: tp.Union[str, float], max_sooner: tp.Optional[float] = None, + percentile: float = 0.3, wakeup_interval: tp.Union[str, float] = '3s', *args, **kwargs): self.seconds = parse_time_string(seconds) self.wakeup_interval = parse_time_string(wakeup_interval) diff --git a/satella/instrumentation/metrics/data.py b/satella/instrumentation/metrics/data.py index 97341736378cc36ef744afd15c3bde34a1c58f87..1d1bf61be4311ba0efada85697bbaaba5d0063fc 100644 --- a/satella/instrumentation/metrics/data.py +++ b/satella/instrumentation/metrics/data.py @@ -196,4 +196,3 @@ class MetricDataCollection(JSONAble): Remove entries marked as internal """ self.values = {value for value in self.values if not value.internal} - diff --git a/satella/instrumentation/metrics/metric_types/base.py b/satella/instrumentation/metrics/metric_types/base.py index f2242f5f924f9b2c9028dce1a1f0bb156140e376..8427195d275dab639b13d0c614788675874d6636 100644 --- a/satella/instrumentation/metrics/metric_types/base.py +++ b/satella/instrumentation/metrics/metric_types/base.py @@ -244,4 +244,5 @@ class EmbeddedSubmetrics(LeafMetric): from .registry import register_metric + register_metric(Metric) diff --git a/satella/instrumentation/metrics/structures/cache_dict.py b/satella/instrumentation/metrics/structures/cache_dict.py index 96f67b58e623765a02085548b294ea75773f42b5..e17f999271b5b5bebf6ebaacd50090a9dc1f5523 100644 --- a/satella/instrumentation/metrics/structures/cache_dict.py +++ b/satella/instrumentation/metrics/structures/cache_dict.py @@ -9,7 +9,6 @@ from ..metric_types.callable import CallableMetric from ..metric_types.counter import CounterMetric from ..metric_types.measurable_mixin import MeasurableMixin - logger = logging.getLogger(__name__) @@ -132,7 +131,7 @@ class MetrifiedExclusiveWritebackCache(ExclusiveWritebackCache[K, V]): cache_miss: tp.Optional[CounterMetric] = None, entries_waiting: tp.Optional[CallableMetric] = None, **kwargs): - super().__init__(*args,**kwargs) + super().__init__(*args, **kwargs) self.cache_miss = cache_miss self.cache_hits = cache_hits if entries_waiting is not None: @@ -146,4 +145,3 @@ class MetrifiedExclusiveWritebackCache(ExclusiveWritebackCache[K, V]): if self.cache_miss: self.cache_miss.runtime(+1) return super().__getitem__(item) - diff --git a/satella/json.py b/satella/json.py index b782225c4129562989d81005da82c491a38c4714..462a398af91bd9e396dae04de7f23b21877c2d47 100644 --- a/satella/json.py +++ b/satella/json.py @@ -4,7 +4,6 @@ import json from satella.coding.typing import NoneType - __all__ = ['JSONEncoder', 'JSONAble', 'json_encode', 'read_json_from_file', 'write_json_to_file', 'write_json_to_file_if_different'] @@ -45,8 +44,8 @@ class JSONEncoder(json.JSONEncoder): try: for slot in o.__slots__: dct[slot] = self.default(getattr(o, slot)) - except AttributeError: # it doesn't have __slots__ either? - return '<an instance of %s>' % (o.__class__.__name__, ) + except AttributeError: # it doesn't have __slots__ either? + return '<an instance of %s>' % (o.__class__.__name__,) return dct diff --git a/satella/os/misc.py b/satella/os/misc.py index ec4c8b8122b299d71375e92645b6761e625b56db..da33c22e48618f9998f007da1e94139cac2d79ba 100644 --- a/satella/os/misc.py +++ b/satella/os/misc.py @@ -34,7 +34,7 @@ def whereis(name: str) -> tp.Iterator[str]: continue if sys.platform.startswith('win'): # a POSIX-specific check - file = file.upper() # paths are not case-sensitive on Windows + file = file.upper() # paths are not case-sensitive on Windows for extension in available_extensions: if file == '%s%s' % (name, extension): diff --git a/satella/time.py b/satella/time.py index 58d8f143e55e3ff0b4b131bdaffc009add75883d..eda61c2cd9b85c446cc3353d0c911fa4f2735691 100644 --- a/satella/time.py +++ b/satella/time.py @@ -370,9 +370,9 @@ class ExponentialBackoff: TIME_MODIFIERS = [ ('s', 1), ('m', 60), - ('h', 60*60), - ('d', 24*60*60), - ('w', 7*24*60*60) + ('h', 60 * 60), + ('d', 24 * 60 * 60), + ('w', 7 * 24 * 60 * 60) ]