From 3359b81874728eb95e4deff69dc85c615a5e72b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Fri, 4 Jun 2021 18:12:20 +0200 Subject: [PATCH] code reformat --- satella/coding/call_hierarchy.py | 2 +- satella/coding/concurrent/id_allocator.py | 2 +- satella/coding/concurrent/queue.py | 1 - satella/coding/concurrent/thread.py | 4 ++-- satella/coding/concurrent/timer.py | 3 ++- satella/coding/decorators/arguments.py | 6 ++++++ satella/coding/decorators/decorators.py | 7 +++++++ satella/coding/decorators/preconditions.py | 1 + satella/coding/decorators/retry_dec.py | 3 +++ satella/coding/misc.py | 6 ++++-- satella/coding/optionals.py | 1 + satella/coding/sequences/iterators.py | 2 +- .../coding/structures/dictionaries/cache_dict.py | 3 ++- .../coding/structures/dictionaries/default.py | 1 + satella/coding/structures/mixins/enums.py | 2 +- satella/coding/structures/push_iterable.py | 1 + satella/coding/structures/syncable_droppable.py | 16 ++++++++-------- satella/coding/structures/tuples.py | 4 ++-- satella/coding/transforms/interpol.py | 4 ++-- satella/coding/transforms/merge_list.py | 1 - satella/coding/typing.py | 3 --- satella/configuration/schema/__init__.py | 3 ++- satella/configuration/schema/basic.py | 6 ++---- satella/configuration/sources/from_dict.py | 2 +- satella/configuration/sources/object_from.py | 1 - satella/exception_handling/dump_to_file.py | 2 +- satella/instrumentation/cpu_time/collector.py | 14 +++++++------- satella/instrumentation/cpu_time/concurrency.py | 3 ++- satella/instrumentation/metrics/data.py | 1 - .../instrumentation/metrics/metric_types/base.py | 1 + .../metrics/structures/cache_dict.py | 4 +--- satella/json.py | 5 ++--- satella/os/misc.py | 2 +- satella/time.py | 6 +++--- 34 files changed, 69 insertions(+), 54 deletions(-) diff --git a/satella/coding/call_hierarchy.py b/satella/coding/call_hierarchy.py index ba642ccd..6d9d91e8 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 6750a67a..c3b974ba 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 c03e2d30..e3f8aa66 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 33440f4f..4ad78f12 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 de0ea0f5..25aeab93 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 4591b4fa..e415ed5b 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 702c2349..8173c622 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 fe6557fc..ae6e55fe 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 098626d1..fdafd645 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 1f3ff3f5..e6277795 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 3121eb18..00be5883 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 7c4f598f..f3800cdb 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 799781dc..8536fe09 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 fa6d9a68..f0035025 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 39b76136..7dd5f95f 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 4daad6ef..e0a6fc3f 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 ed6dd348..4c40df74 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 9eb8a589..98da0c72 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 fc817a12..ab80ecbf 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 6b3aa8ba..99a03839 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 68a94fa0..8b79d2cf 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 e1355704..3e87cdbc 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 03464e8a..f451d800 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 ecfe8cf7..8300a42f 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 e780a284..1bfc4982 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 2a958c92..de294049 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 e3413307..f5e820be 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 177871a7..26f7438c 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 97341736..1d1bf61b 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 f2242f5f..8427195d 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 96f67b58..e17f9992 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 b782225c..462a398a 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 ec4c8b81..da33c22e 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 58d8f143..eda61c2c 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) ] -- GitLab