Skip to content
Snippets Groups Projects
Commit 41dc075b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

minor refactor for slots

parent c9a92380
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ class Call:
"""
A call to given function with a given set of arguments
"""
__slots__ = ('fn', 'args', 'kwargs')
__slots__ = 'fn', 'args', 'kwargs'
def __init__(self, fn, *args, **kwargs):
warnings.warn('This module is experimental, use at your own peril', ExperimentalWarning)
......@@ -81,7 +81,7 @@ class CallWithArgumentSet(Call):
"""
Call a function with a set of arguments provided by the environment
"""
__slots__ = ('fn', 'arg_set_no')
__slots__ = 'fn', 'arg_set_no'
def __init__(self, fn, arg_set_no: int = 0):
warnings.warn('This module is experimental, use at your own peril', ExperimentalWarning)
......@@ -106,7 +106,7 @@ class CallIf(Call):
"""
Call a function only if fn_if_call returned True
"""
__slots__ = ('fn_to_call', 'fn_call_if')
__slots__ = 'fn_to_call', 'fn_call_if'
def __init__(self, fn_if_call: Call, fn_to_call: Call):
warnings.warn('This module is experimental, use at your own peril', ExperimentalWarning)
......@@ -135,7 +135,7 @@ class Reduce(Call):
:param do_parallel: whether try to execute these calls in parallel, if possible.
Parallel execution will be done only if an executor is given in the execution environment.
"""
__slots__ = ('reducing_op', 'starting_value', 'do_parallel', 'callables')
__slots__ = 'reducing_op', 'starting_value', 'do_parallel', 'callables'
def __init__(self, *callables: Call,
reducing_op: tp.Callable[[tp.Any, tp.Any], tp.Any] = lambda a, b: None,
......
......@@ -23,7 +23,7 @@ class ThreadCollection:
length check.
"""
__slots__ = ('threads', )
__slots__ = 'threads',
def __len__(self):
return len(self.threads)
......
......@@ -113,7 +113,7 @@ class ListDeleter(tp.Generic[T]):
You can pass any type of object here, as long as it supports pop(position) and __getitem__
"""
__slots__ = ('list_to_process', 'current_index', 'indices_to_delete', 'direction')
__slots__ = 'list_to_process', 'current_index', 'indices_to_delete', 'direction'
def __init__(self, list_to_process: tp.MutableSequence[T]):
self.list_to_process = list_to_process
......
......@@ -19,7 +19,7 @@ class expect_exception:
:param args: args to provide to constructor
:param kwargs: kwargs to provide to constructor
"""
__slots__ = ('exc_to_except', 'else_raise', 'else_raise_args', 'else_raise_kwargs')
__slots__ = 'exc_to_except', 'else_raise', 'else_raise_args', 'else_raise_kwargs'
def __init__(self, exc_to_except: ExceptionList, else_raise: tp.Type[Exception],
*args, **kwargs):
......
......@@ -47,7 +47,7 @@ class SelfClosingGenerator:
You can also use it as a context manager, to decouple finalizing the generator from the GC
collection
"""
__slots__ = ('generator', 'stopped')
__slots__ = 'generator', 'stopped'
def __init__(self, generator: tp.Union[tp.Generator, tp.Callable[[tp.Any], tp.Generator]]):
self.generator = generator
......@@ -103,7 +103,7 @@ class hint_with_length:
You must provide either length or length_factory. Giving them both is wrong, and
will result in ValueError
"""
__slots__ = ('generator', 'length', 'length_factory')
__slots__ = 'generator', 'length', 'length_factory'
def __init__(self, generator: tp.Generator, length: tp.Optional[int],
length_factory: tp.Optional[NoArgCallable[int]] = None):
......
......@@ -15,7 +15,7 @@ class Loadable(metaclass=ABCMeta):
If False, you will need to load it on-demand via :func:`must_be_loaded` decorator.
"""
__slots__ = ('_loaded',)
__slots__ = '_loaded',
def __init__(self, load_lazy: bool = False):
self._loaded = False
......
......@@ -20,7 +20,7 @@ class DevNullFilelikeObject:
"""
A /dev/null filelike object. For multiple uses.
"""
__slots__ = ('is_closed',)
__slots__ = 'is_closed',
def __init__(self):
self.is_closed = False
......
......@@ -339,7 +339,7 @@ class ExponentialBackoff:
:param sleep_fun: function used to sleep. Will accept a single argument - number of
seconds to wait
"""
__slots__ = ('start', 'limit', 'counter', 'sleep_fun')
__slots__ = 'start', 'limit', 'counter', 'sleep_fun'
def __init__(self, start: float = 1, limit: float = 30,
sleep_fun: tp.Callable[[float], None] = sleep):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment