Repository: pytransitions/transitions (language: python)

Issue:
Remove leading whitespace in docstrings
### Discussed in https://github.com/pytransitions/transitions/discussions/598

Most docstrings in transitions contain a leading whitespace. These whitespaces should be removed to follow official docstring guidelines more accurately.


Discussion / hints:

Fix patch:
diff --git a/transitions/core.py b/transitions/core.py
index 00db8f2d..8b42d553 100644
--- a/transitions/core.py
+++ b/transitions/core.py
@@ -19,10 +19,10 @@
 except ImportError:  # pragma: no cover
     # If enum is not available, create dummy classes for type checks
     class Enum:  # type:ignore
-        """ This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support."""
 
     class EnumMeta:  # type:ignore
-        """ This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support."""
 
 import inspect
 import itertools
@@ -113,30 +113,30 @@ def __init__(self, name, on_enter=None, on_exit=None,
 
     @property
     def name(self):
-        """ The name of the state. """
+        """The name of the state."""
         if isinstance(self._name, Enum):
             return self._name.name
         return self._name
 
     @property
     def value(self):
-        """ The state's value. For string states this will be equivalent to the name attribute. """
+        """The state's value. For string states this will be equivalent to the name attribute."""
         return self._name
 
     def enter(self, event_data):
-        """ Triggered when a state is entered. """
+        """Triggered when a state is entered."""
         _LOGGER.debug("%sEntering state %s. Processing callbacks...", event_data.machine.name, self.name)
         event_data.machine.callbacks(self.on_enter, event_data)
         _LOGGER.info("%sFinished processing state %s enter callbacks.", event_data.machine.name, self.name)
 
     def exit(self, event_data):
-        """ Triggered when a state is exited. """
+        """Triggered when a state is exited."""
         _LOGGER.debug("%sExiting state %s. Processing callbacks...", event_data.machine.name, self.name)
         event_data.machine.callbacks(self.on_exit, event_data)
         _LOGGER.info("%sFinished processing state %s exit callbacks.", event_data.machine.name, self.name)
 
     def add_callback(self, trigger, func):
-        """ Add a new enter or exit callback.
+        """Add a new enter or exit callback.
         Args:
             trigger (str): The type of triggering event. Must be one of
                 'enter' or 'exit'.
@@ -150,7 +150,7 @@ def __repr__(self):
 
 
 class Condition(object):
-    """ A helper class to call condition checks in the intended way.
+    """A helper class to call condition checks in the intended way.
 
     Attributes:
         func (str or callable): The function to call for the condition check
@@ -176,7 +176,7 @@ def __init__(self, func, target=True):
         self.target = target
 
     def check(self, event_data):
-        """ Check whether the condition passes.
+        """Check whether the condition passes.
         Args:
             event_data (EventData): An EventData instance to pass to the
                 condition (if event sending is enabled) or to extract arguments
@@ -194,7 +194,7 @@ def __repr__(self):
 
 
 class Transition(object):
-    """ Representation of a transition managed by a ``Machine`` instance.
+    """Representation of a transition managed by a ``Machine`` instance.
 
     Attributes:
         source (str): Source state of the transition.
@@ -255,7 +255,7 @@ def _eval_conditions(self, event_data):
         return True
 
     def execute(self, event_data):
-        """ Execute the transition.
+        """Execute the transition.
         Args:
             event_data: An instance of class EventData.
         Returns: boolean indicating whether the transition was
@@ -287,7 +287,7 @@ def _change_state(self, event_data):
         event_data.machine.get_state(self.dest).enter(event_data)
 
     def add_callback(self, trigger, func):
-        """ Add a new before, after, or prepare callback.
+        """Add a new before, after, or prepare callback.
         Args:
             trigger (str): The type of triggering event. Must be one of
                 'before', 'after' or 'prepare'.
@@ -302,7 +302,7 @@ def __repr__(self):
 
 
 class EventData(object):
-    """ Collection of relevant data related to the ongoing transition attempt.
+    """Collection of relevant data related to the ongoing transition attempt.
 
     Attributes:
         state (State): The State from which the Event was triggered.
@@ -341,7 +341,7 @@ def __init__(self, state, event, machine, model, args, kwargs):
         self.result = False
 
     def update(self, state):
-        """ Updates the EventData object with the passed state.
+        """Updates the EventData object with the passed state.
 
         Attributes:
             state (State, str or Enum): The state object, enum member or string to assign to EventData.
@@ -356,7 +356,7 @@ def __repr__(self):
 
 
 class Event(object):
-    """ A collection of transitions assigned to the same trigger
+    """A collection of transitions assigned to the same trigger
 
     """
 
@@ -373,7 +373,7 @@ def __init__(self, name, machine):
         self.transitions = defaultdict(list)
 
     def add_transition(self, transition):
-        """ Add a transition to the list of potential transitions.
+        """Add a transition to the list of potential transitions.
         Args:
             transition (Transition): The Transition instance to add to the
                 list.
@@ -381,7 +381,7 @@ def add_transition(self, transition):
         self.transitions[transition.source].append(transition)
 
     def trigger(self, model, *args, **kwargs):
-        """ Executes all transitions that match the current state,
+        """Executes all transitions that match the current state,
         halting as soon as one successfully completes. More precisely, it prepares a partial
         of the internal ``_trigger`` function, passes this to ``Machine._process``.
         It is up to the machine's configuration of the Event whether processing happens queued (sequentially) or
@@ -402,7 +402,7 @@ def trigger(self, model, *args, **kwargs):
         return self.machine._process(func)
 
     def _trigger(self, event_data):
-        """ Internal trigger function called by the ``Machine`` instance. This should not
+        """Internal trigger function called by the ``Machine`` instance. This should not
         be called directly but via the public method ``Machine.process``.
         Args:
             event_data (EventData): The currently processed event. State, result and (potentially) error might be
@@ -456,7 +456,7 @@ def __repr__(self):
         return "<%s('%s')@%s>" % (type(self).__name__, self.name, id(self))
 
     def add_callback(self, trigger, func):
-        """ Add a new before or after callback to all available transitions.
+        """Add a new before or after callback to all available transitions.
         Args:
             trigger (str): The type of triggering event. Must be one of
                 'before', 'after' or 'prepare'.
@@ -467,7 +467,7 @@ def add_callback(self, trigger, func):
 
 
 class Machine(object):
-    """ Machine manages states, transitions and models. In case it is initialized without a specific model
+    """Machine manages states, transitions and models. In case it is initialized without a specific model
     (or specifically no model), it will also act as a model itself. Machine takes also care of decorating
     models with conveniences functions related to added transitions and states during runtime.
 
@@ -606,7 +606,7 @@ def __init__(self, model=self_literal, states=None, initial='initial', transitio
             self.add_model(model)
 
     def add_model(self, model, initial=None):
-        """ Register a model with the state machine, initializing triggers and callbacks. """
+        """Register a model with the state machine, initializing triggers and callbacks."""
         models = listify(model)
 
         if initial is None:
@@ -629,7 +629,7 @@ def add_model(self, model, initial=None):
                 self.models.append(mod)
 
     def remove_model(self, model):
-        """ Remove a model from the state machine. The model will still contain all previously added triggers
+        """Remove a model from the state machine. The model will still contain all previously added triggers
         and callbacks, but will not receive updates when states or transitions are added to the Machine.
         If an event queue is used, all queued events of that model will be removed."""
         models = listify(model)
@@ -655,7 +655,7 @@ def _create_state(cls, *args, **kwargs):
 
     @property
     def initial(self):
-        """ Return the initial state. """
+        """Return the initial state."""
         return self._initial
 
     @initial.setter
@@ -674,12 +674,12 @@ def initial(self, value):
 
     @property
     def has_queue(self):
-        """ Return boolean indicating if machine has queue or not """
+        """Return boolean indicating if machine has queue or not"""
         return self._queued
 
     @property
     def model(self):
-        """ List of models attached to the machine. For backwards compatibility, the property will
+        """List of models attached to the machine. For backwards compatibility, the property will
         return the model instance itself instead of the underlying list  if there is only one attached
         to the machine.
         """
@@ -741,7 +741,7 @@ def on_exception(self, value):
         self._on_exception = listify(value)
 
     def get_state(self, state):
-        """ Return the State instance with the passed name. """
+        """Return the State instance with the passed name."""
         if isinstance(state, Enum):
             state = state.name
         if state not in self.states:
@@ -751,7 +751,7 @@ def get_state(self, state):
     # In theory this function could be static. This however causes some issues related to inheritance and
     # pickling down the chain.
     def is_state(self, state, model):
-        """ Check whether the current state matches the named state. This function is not called directly
+        """Check whether the current state matches the named state. This function is not called directly
             but assigned as partials to model instances (e.g. is_A -> partial(_is_state, 'A', model)).
         Args:
             state (str or Enum): name of the checked state or Enum
@@ -786,13 +786,13 @@ def set_state(self, state, model=None):
             setattr(mod, self.model_attribute, state.value)
 
     def add_state(self, states, on_enter=None, on_exit=None, ignore_invalid_triggers=None, **kwargs):
-        """ Alias for add_states. """
+        """Alias for add_states."""
         self.add_states(states=states, on_enter=on_enter, on_exit=on_exit,
                         ignore_invalid_triggers=ignore_invalid_triggers, **kwargs)
 
     def add_states(self, states, on_enter=None, on_exit=None,
                    ignore_invalid_triggers=None, **kwargs):
-        """ Add new state(s).
+        """Add new state(s).
         Args:
             states (list, str, dict, Enum or State): a list, a State instance, the
                 name of a new state, an enumeration (member) or a dict with keywords to pass on to the
@@ -924,7 +924,7 @@ def _get_trigger(self, model, trigger_name, *args, **kwargs):
         return event.trigger(model, *args, **kwargs)
 
     def get_triggers(self, *args):
-        """ Collects all triggers FROM certain states.
+        """Collects all triggers FROM certain states.
         Args:
             *args: Tuple of source states.
 
@@ -936,7 +936,7 @@ def get_triggers(self, *args):
 
     def add_transition(self, trigger, source, dest, conditions=None,
                        unless=None, before=None, after=None, prepare=None, **kwargs):
-        """ Create a new Transition instance and add it to the internal list.
+        """Create a new Transition instance and add it to the internal list.
         Args:
             trigger (str): The name of the method that will trigger the
                 transition. This will be attached to the currently specified
@@ -993,7 +993,7 @@ def add_transition(self, trigger, source, dest, conditions=None,
             self.events[trigger].add_transition(_trans)
 
     def add_transitions(self, transitions):
-        """ Add several transitions.
+        """Add several transitions.
 
         Args:
             transitions (list): A list of transitions.
@@ -1009,7 +1009,7 @@ def add_ordered_transitions(self, states=None, trigger='next_state',
                                 loop=True, loop_includes_initial=True,
                                 conditions=None, unless=None, before=None,
                                 after=None, prepare=None, **kwargs):
-        """ Add a set of transitions that move linearly from state to state.
+        """Add a set of transitions that move linearly from state to state.
         Args:
             states (list): A list of state names defining the order of the
                 transitions. E.g., ['A', 'B', 'C'] will generate transitions
@@ -1080,7 +1080,7 @@ def add_ordered_transitions(self, states=None, trigger='next_state',
                                 **kwargs)
 
     def get_transitions(self, trigger="", source="*", dest="*"):
-        """ Return the transitions from the Machine.
+        """Return the transitions from the Machine.
         Args:
             trigger (str): Trigger name of the transition.
             source (str, Enum or State): Limits list to transitions from a certain state.
@@ -1105,7 +1105,7 @@ def get_transitions(self, trigger="", source="*", dest="*"):
                                                             target_dest or transition.dest)]
 
     def remove_transition(self, trigger, source="*", dest="*"):
-        """ Removes a transition from the Machine and all models.
+        """Removes a transition from the Machine and all models.
         Args:
             trigger (str): Trigger name of the transition.
             source (str, Enum or State): Limits removal to transitions from a certain state.
@@ -1132,7 +1132,7 @@ def remove_transition(self, trigger, source="*", dest="*"):
             del self.events[trigger]
 
     def dispatch(self, trigger, *args, **kwargs):
-        """ Trigger an event on all models assigned to the machine.
+        """Trigger an event on all models assigned to the machine.
         Args:
             trigger (str): Event name
             *args (list): List of arguments passed to the event trigger
@@ -1143,13 +1143,13 @@ def dispatch(self, trigger, *args, **kwargs):
         return all(getattr(model, trigger)(*args, **kwargs) for model in self.models)
 
     def callbacks(self, funcs, event_data):
-        """ Triggers a list of callbacks """
+        """Triggers a list of callbacks"""
         for func in funcs:
             self.callback(func, event_data)
             _LOGGER.info("%sExecuted callback '%s'", self.name, func)
 
     def callback(self, func, event_data):
-        """ Trigger a callback function with passed event_data parameters. In case func is a string,
+        """Trigger a callback function with passed event_data parameters. In case func is a string,
             the callable will be resolved from the passed model in event_data. This function is not intended to
             be called directly but through state and transition callback definitions.
         Args:
@@ -1170,7 +1170,7 @@ def callback(self, func, event_data):
 
     @staticmethod
     def resolve_callable(func, event_data):
-        """ Converts a model's property name, method name or a path to a callable into a callable.
+        """Converts a model's property name, method name or a path to a callable into a callable.
             If func is not a string it will be returned unaltered.
         Args:
             func (str or callable): Property name, method name or a path to a callable
@@ -1277,7 +1277,7 @@ def __getattr__(self, name):
 
 
 class MachineError(Exception):
-    """ MachineError is used for issues related to state transitions and current states.
+    """MachineError is used for issues related to state transitions and current states.
     For instance, it is raised for invalid transitions or machine configuration issues.
     """
 
diff --git a/transitions/extensions/asyncio.py b/transitions/extensions/asyncio.py
index 6bbfc32d..dd3faf5f 100644
--- a/transitions/extensions/asyncio.py
+++ b/transitions/extensions/asyncio.py
@@ -32,10 +32,10 @@
 
 
 class AsyncState(State):
-    """ A persistent representation of a state managed by a ``Machine``. Callback execution is done asynchronously. """
+    """A persistent representation of a state managed by a ``Machine``. Callback execution is done asynchronously."""
 
     async def enter(self, event_data):
-        """ Triggered when a state is entered.
+        """Triggered when a state is entered.
         Args:
             event_data: (AsyncEventData): The currently processed event.
         """
@@ -44,7 +44,7 @@ async def enter(self, event_data):
         _LOGGER.info("%sFinished processing state %s enter callbacks.", event_data.machine.name, self.name)
 
     async def exit(self, event_data):
-        """ Triggered when a state is exited.
+        """Triggered when a state is exited.
         Args:
             event_data: (AsyncEventData): The currently processed event.
         """
@@ -54,7 +54,7 @@ async def exit(self, event_data):
 
 
 class NestedAsyncState(NestedState, AsyncState):
-    """ A state that allows substates. Callback execution is done asynchronously. """
+    """A state that allows substates. Callback execution is done asynchronously."""
 
     async def scoped_enter(self, event_data, scope=None):
         self._scope = scope or []
@@ -68,10 +68,10 @@ async def scoped_exit(self, event_data, scope=None):
 
 
 class AsyncCondition(Condition):
-    """ A helper class to await condition checks in the intended way. """
+    """A helper class to await condition checks in the intended way."""
 
     async def check(self, event_data):
-        """ Check whether the condition passes.
+        """Check whether the condition passes.
         Args:
             event_data (EventData): An EventData instance to pass to the
                 condition (if event sending is enabled) or to extract arguments
@@ -87,7 +87,7 @@ async def check(self, event_data):
 
 
 class AsyncTransition(Transition):
-    """ Representation of an asynchronous transition managed by a ``AsyncMachine`` instance. """
+    """Representation of an asynchronous transition managed by a ``AsyncMachine`` instance."""
 
     condition_cls = AsyncCondition
 
@@ -99,7 +99,7 @@ async def _eval_conditions(self, event_data):
         return True
 
     async def execute(self, event_data):
-        """ Executes the transition.
+        """Executes the transition.
         Args:
             event_data (EventData): An instance of class EventData.
         Returns: boolean indicating whether or not the transition was
@@ -142,7 +142,7 @@ async def _change_state(self, event_data):
 
 
 class NestedAsyncTransition(AsyncTransition, NestedTransition):
-    """ Representation of an asynchronous transition managed by a ``HierarchicalMachine`` instance. """
+    """Representation of an asynchronous transition managed by a ``HierarchicalMachine`` instance."""
     async def _change_state(self, event_data):
         if hasattr(event_data.machine, "model_graphs"):
             graph = event_data.machine.model_graphs[id(event_data.model)]
@@ -157,14 +157,14 @@ async def _change_state(self, event_data):
 
 
 class AsyncEventData(EventData):
-    """ A redefinition of the base EventData intended to easy type checking. """
+    """A redefinition of the base EventData intended to easy type checking."""
 
 
 class AsyncEvent(Event):
-    """ A collection of transitions assigned to the same trigger """
+    """A collection of transitions assigned to the same trigger"""
 
     async def trigger(self, model, *args, **kwargs):
-        """ Serially execute all transitions that match the current state,
+        """Serially execute all transitions that match the current state,
         halting as soon as one successfully completes. Note that `AsyncEvent` triggers must be awaited.
         Args:
             args and kwargs: Optional positional or named arguments that will
@@ -204,12 +204,12 @@ async def _process(self, event_data):
 
 
 class NestedAsyncEvent(NestedEvent):
-    """ A collection of transitions assigned to the same trigger.
+    """A collection of transitions assigned to the same trigger.
     This Event requires a (subclass of) `HierarchicalAsyncMachine`.
     """
 
     async def trigger_nested(self, event_data):
-        """ Serially execute all transitions that match the current state,
+        """Serially execute all transitions that match the current state,
         halting as soon as one successfully completes. NOTE: This should only
         be called by HierarchicalMachine instances.
         Args:
@@ -251,7 +251,7 @@ async def _process(self, event_data):
 
 
 class AsyncMachine(Machine):
-    """ Machine manages states, transitions and models. In case it is initialized without a specific model
+    """Machine manages states, transitions and models. In case it is initialized without a specific model
     (or specifically no model), it will also act as a model itself. Machine takes also care of decorating
     models with conveniences functions related to added transitions and states during runtime.
 
@@ -312,7 +312,7 @@ def add_model(self, model, initial=None):
                 self._transition_queue_dict[id(self) if mod is self.self_literal else id(mod)] = deque()
 
     async def dispatch(self, trigger, *args, **kwargs):
-        """ Trigger an event on all models assigned to the machine.
+        """Trigger an event on all models assigned to the machine.
         Args:
             trigger (str): Event name
             *args (list): List of arguments passed to the event trigger
@@ -324,11 +324,11 @@ async def dispatch(self, trigger, *args, **kwargs):
         return all(results)
 
     async def callbacks(self, funcs, event_data):
-        """ Triggers a list of callbacks """
+        """Triggers a list of callbacks"""
         await self.await_all([partial(event_data.machine.callback, func, event_data) for func in funcs])
 
     async def callback(self, func, event_data):
-        """ Trigger a callback function with passed event_data parameters. In case func is a string,
+        """Trigger a callback function with passed event_data parameters. In case func is a string,
             the callable will be resolved from the passed model in event_data. This function is not intended to
             be called directly but through state and transition callback definitions.
         Args:
@@ -401,7 +401,7 @@ async def process_context(self, func, model):
         return res
 
     def remove_model(self, model):
-        """ Remove a model from the state machine. The model will still contain all previously added triggers
+        """Remove a model from the state machine. The model will still contain all previously added triggers
         and callbacks, but will not receive updates when states or transitions are added to the Machine.
         If an event queue is used, all queued events of that model will be removed."""
         models = listify(model)
@@ -467,7 +467,7 @@ async def _process_async(self, trigger, model):
 
 
 class HierarchicalAsyncMachine(HierarchicalMachine, AsyncMachine):
-    """ Asynchronous variant of transitions.extensions.nesting.HierarchicalMachine.
+    """Asynchronous variant of transitions.extensions.nesting.HierarchicalMachine.
         An asynchronous hierarchical machine REQUIRES AsyncNestedStates, AsyncNestedEvent and AsyncNestedTransitions
         (or any subclass of it) to operate.
     """
@@ -477,7 +477,7 @@ class HierarchicalAsyncMachine(HierarchicalMachine, AsyncMachine):
     event_cls = NestedAsyncEvent
 
     async def trigger_event(self, model, trigger, *args, **kwargs):
-        """ Processes events recursively and forwards arguments if suitable events are found.
+        """Processes events recursively and forwards arguments if suitable events are found.
         This function is usually bound to models with model and trigger arguments already
         resolved as a partial. Execution will halt when a nested transition has been executed
         successfully.
@@ -661,7 +661,7 @@ def on_timeout(self):
 
     @on_timeout.setter
     def on_timeout(self, value):
-        """ Listifies passed values and assigns them to on_timeout."""
+        """Listifies passed values and assigns them to on_timeout."""
         self._on_timeout = listify(value)
 
 
diff --git a/transitions/extensions/diagrams.py b/transitions/extensions/diagrams.py
index e2f0c56c..cbee76eb 100644
--- a/transitions/extensions/diagrams.py
+++ b/transitions/extensions/diagrams.py
@@ -27,7 +27,7 @@
 
 
 class TransitionGraphSupport(Transition):
-    """ Transition used in conjunction with (Nested)Graphs to update graphs whenever a transition is
+    """Transition used in conjunction with (Nested)Graphs to update graphs whenever a transition is
         conducted.
     """
 
@@ -51,7 +51,7 @@ def _change_state(self, event_data):
 
 
 class GraphMachine(MarkupMachine):
-    """ Extends transitions.core.Machine with graph support.
+    """Extends transitions.core.Machine with graph support.
         Is also used as a mixin for HierarchicalMachine.
         Attributes:
             _pickle_blacklist (list): Objects that should not/do not need to be pickled.
@@ -152,7 +152,7 @@ def __init__(self, model=MarkupMachine.self_literal, states=None, initial='initi
             setattr(self, "get_graph", self.get_combined_graph)
 
     def _init_graphviz_engine(self, use_pygraphviz):
-        """ Imports diagrams (py)graphviz backend based on machine configuration """
+        """Imports diagrams (py)graphviz backend based on machine configuration"""
         if use_pygraphviz:
             try:
                 # state class needs to have a separator and machine needs to be a context manager
@@ -182,7 +182,7 @@ def _init_graphviz_engine(self, use_pygraphviz):
         return Graph
 
     def _get_graph(self, model, title=None, force_new=False, show_roi=False):
-        """ This method will be bound as a partial to models and return a graph object to be drawn or manipulated.
+        """This method will be bound as a partial to models and return a graph object to be drawn or manipulated.
         Args:
             model (object): The model that `_get_graph` was bound to. This parameter will be set by `GraphMachine`.
             title (str): The title of the created graph.
@@ -207,7 +207,7 @@ def _get_graph(self, model, title=None, force_new=False, show_roi=False):
         return graph.get_graph(title=title, roi_state=getattr(model, self.model_attribute) if show_roi else None)
 
     def get_combined_graph(self, title=None, force_new=False, show_roi=False):
-        """ This method is currently equivalent to 'get_graph' of the first machine's model.
+        """This method is currently equivalent to 'get_graph' of the first machine's model.
         In future releases of transitions, this function will return a combined graph with active states
         of all models.
         Args:
@@ -239,7 +239,7 @@ def add_model(self, model, initial=None):
     def add_states(
         self, states, on_enter=None, on_exit=None, ignore_invalid_triggers=None, **kwargs
     ):
-        """ Calls the base method and regenerates all models's graphs. """
+        """Calls the base method and regenerates all models's graphs."""
         super(GraphMachine, self).add_states(
             states,
             on_enter=on_enter,
@@ -252,7 +252,7 @@ def add_states(
 
     def add_transition(self, trigger, source, dest, conditions=None, unless=None, before=None, after=None,
                        prepare=None, **kwargs):
-        """ Calls the base method and regenerates all models's graphs. """
+        """Calls the base method and regenerates all models's graphs."""
         super(GraphMachine, self).add_transition(trigger, source, dest, conditions=conditions, unless=unless,
                                                  before=before, after=after, prepare=prepare, **kwargs)
         for model in self.models:
diff --git a/transitions/extensions/diagrams_base.py b/transitions/extensions/diagrams_base.py
index aee2257b..c33e7e22 100644
--- a/transitions/extensions/diagrams_base.py
+++ b/transitions/extensions/diagrams_base.py
@@ -17,7 +17,7 @@
 
 @six.add_metaclass(abc.ABCMeta)
 class BaseGraph(object):
-    """ Provides the common foundation for graphs generated either with pygraphviz or graphviz. This abstract class
+    """Provides the common foundation for graphs generated either with pygraphviz or graphviz. This abstract class
     should not be instantiated directly. Use .(py)graphviz.(Nested)Graph instead.
     Attributes:
         machine (GraphMachine): The associated GraphMachine
@@ -31,11 +31,11 @@ def __init__(self, machine):
 
     @abc.abstractmethod
     def generate(self):
-        """ Triggers the generation of a graph. """
+        """Triggers the generation of a graph."""
 
     @abc.abstractmethod
     def set_previous_transition(self, src, dst):
-        """ Sets the styling of an edge to 'previous'
+        """Sets the styling of an edge to 'previous'
         Args:
             src (str): Name of the source state
             dst (str): Name of the destination
@@ -43,11 +43,11 @@ def set_previous_transition(self, src, dst):
 
     @abc.abstractmethod
     def reset_styling(self):
-        """ Resets the styling of the currently generated graph. """
+        """Resets the styling of the currently generated graph."""
 
     @abc.abstractmethod
     def set_node_style(self, state, style):
-        """ Sets the style of nodes associated with a model state
+        """Sets the style of nodes associated with a model state
         Args:
             state (str, Enum or list): Name of the state(s) or Enum(s)
             style (str): Name of the style
@@ -55,7 +55,7 @@ def set_node_style(self, state, style):
 
     @abc.abstractmethod
     def get_graph(self, title=None, roi_state=None):
-        """ Returns a graph object.
+        """Returns a graph object.
         Args:
             title (str): Title of the generated graph
             roi_state (State): If not None, the returned graph will only contain edges and states connected to it.
diff --git a/transitions/extensions/diagrams_graphviz.py b/transitions/extensions/diagrams_graphviz.py
index 5eeaef6b..8bef57db 100644
--- a/transitions/extensions/diagrams_graphviz.py
+++ b/transitions/extensions/diagrams_graphviz.py
@@ -23,7 +23,7 @@
 
 
 class Graph(BaseGraph):
-    """ Graph creation for transitions.core.Machine.
+    """Graph creation for transitions.core.Machine.
         Attributes:
             custom_styles (dict): A dictionary of styles for the current graph
     """
@@ -74,7 +74,7 @@ def _add_edges(self, transitions, container):
                 )
 
     def generate(self):
-        """ Triggers the generation of a graph. With graphviz backend, this does nothing since graph trees need to be
+        """Triggers the generation of a graph. With graphviz backend, this does nothing since graph trees need to be
         build from scratch with the configured styles.
         """
         if not pgv:  # pragma: no cover
@@ -147,7 +147,7 @@ def draw(self, graph, filename, format=None, prog="dot", args=""):
 
 
 class NestedGraph(Graph):
-    """ Graph creation support for transitions.extensions.nested.HierarchicalGraphMachine. """
+    """Graph creation support for transitions.extensions.nested.HierarchicalGraphMachine."""
 
     def __init__(self, *args, **kwargs):
         self._cluster_states = []
diff --git a/transitions/extensions/diagrams_pygraphviz.py b/transitions/extensions/diagrams_pygraphviz.py
index 46b891d2..20ccaa8b 100644
--- a/transitions/extensions/diagrams_pygraphviz.py
+++ b/transitions/extensions/diagrams_pygraphviz.py
@@ -21,7 +21,7 @@
 
 
 class Graph(BaseGraph):
-    """ Graph creation for transitions.core.Machine. """
+    """Graph creation for transitions.core.Machine."""
 
     def _add_nodes(self, states, container):
         for state in states:
@@ -116,7 +116,7 @@ def reset_styling(self):
 
 
 class NestedGraph(Graph):
-    """ Graph creation support for transitions.extensions.nested.HierarchicalGraphMachine. """
+    """Graph creation support for transitions.extensions.nested.HierarchicalGraphMachine."""
 
     def __init__(self, *args, **kwargs):
         self.seen_transitions = []
@@ -220,7 +220,7 @@ def set_previous_transition(self, src, dst):
 
 
 def _get_subgraph(graph, name):
-    """ Searches for subgraphs in a graph.
+    """Searches for subgraphs in a graph.
     Args:
         g (AGraph): Container to be searched.
         name (str): Name of the cluster.
diff --git a/transitions/extensions/factory.py b/transitions/extensions/factory.py
index 7b5b899e..e56541c6 100644
--- a/transitions/extensions/factory.py
+++ b/transitions/extensions/factory.py
@@ -22,25 +22,25 @@
     from transitions.extensions.asyncio import HierarchicalAsyncMachine, NestedAsyncTransition
 except (ImportError, SyntaxError):  # pragma: no cover
     class AsyncMachine(Machine):  # type: ignore
-        """ A mock of AsyncMachine for Python 3.6 and earlier. """
+        """A mock of AsyncMachine for Python 3.6 and earlier."""
 
     class AsyncTransition(Transition):  # type: ignore
-        """ A mock of AsyncTransition for Python 3.6 and earlier. """
+        """A mock of AsyncTransition for Python 3.6 and earlier."""
 
     class HierarchicalAsyncMachine(HierarchicalMachine):  # type: ignore
-        """ A mock of HierarchicalAsyncMachine for Python 3.6 and earlier. """
+        """A mock of HierarchicalAsyncMachine for Python 3.6 and earlier."""
 
     class NestedAsyncTransition(NestedTransition):  # type: ignore
-        """ A mock of NestedAsyncTransition for Python 3.6 and earlier. """
+        """A mock of NestedAsyncTransition for Python 3.6 and earlier."""
 
 
 class MachineFactory(object):
-    """ Convenience factory for machine class retrieval. """
+    """Convenience factory for machine class retrieval."""
 
     # get one of the predefined classes which fulfill the criteria
     @staticmethod
     def get_predefined(graph=False, nested=False, locked=False, asyncio=False):
-        """ A function to retrieve machine classes by required functionality.
+        """A function to retrieve machine classes by required functionality.
         Args:
             graph (bool): Whether the returned class should contain graph support.
             nested: Whether the returned machine class should support nested states.
@@ -96,13 +96,13 @@ def format_references(func):
 
 
 class AsyncGraphMachine(GraphMachine, AsyncMachine):
-    """ A machine that supports asynchronous event/callback processing with Graphviz support. """
+    """A machine that supports asynchronous event/callback processing with Graphviz support."""
 
     transition_cls = AsyncTransition
 
 
 class HierarchicalAsyncGraphMachine(GraphMachine, HierarchicalAsyncMachine):
-    """ A hierarchical machine that supports asynchronous event/callback processing with Graphviz support. """
+    """A hierarchical machine that supports asynchronous event/callback processing with Graphviz support."""
 
     transition_cls = NestedAsyncTransition
 
diff --git a/transitions/extensions/locking.py b/transitions/extensions/locking.py
index 8a254149..3c2bf6df 100644
--- a/transitions/extensions/locking.py
+++ b/transitions/extensions/locking.py
@@ -31,7 +31,7 @@
 
     @contextmanager
     def nested(*contexts):
-        """ Reimplementation of nested in Python 3. """
+        """Reimplementation of nested in Python 3."""
         with ExitStack() as stack:
             for ctx in contexts:
                 stack.enter_context(ctx)
@@ -39,7 +39,7 @@ def nested(*contexts):
 
 
 class PicklableLock:
-    """ A wrapper for threading.Lock which discards its state during pickling and
+    """A wrapper for threading.Lock which discards its state during pickling and
         is reinitialized unlocked when unpickled.
     """
 
@@ -60,7 +60,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
 
 
 class IdentManager:
-    """  Manages the identity of threads to detect whether the current thread already has a lock. """
+    """Manages the identity of threads to detect whether the current thread already has a lock."""
 
     def __init__(self):
         self.current = 0
@@ -73,10 +73,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
 
 
 class LockedEvent(Event):
-    """ An event type which uses the parent's machine context map when triggered. """
+    """An event type which uses the parent's machine context map when triggered."""
 
     def trigger(self, model, *args, **kwargs):
-        """ Extends transitions.core.Event.trigger by using locks/machine contexts. """
+        """Extends transitions.core.Event.trigger by using locks/machine contexts."""
         # pylint: disable=protected-access
         # noinspection PyProtectedMember
         # LockedMachine._locked should not be called somewhere else. That's why it should not be exposed
@@ -89,7 +89,7 @@ def trigger(self, model, *args, **kwargs):
 
 
 class LockedMachine(Machine):
-    """ Machine class which manages contexts. In it's default version the machine uses a `threading.Lock`
+    """Machine class which manages contexts. In it's default version the machine uses a `threading.Lock`
         context to lock access to its methods and event triggers bound to model objects.
     Attributes:
         machine_context (dict): A dict of context managers to be entered whenever a machine method is
@@ -137,7 +137,7 @@ def __setstate__(self, state):
         del self._model_context_map_store
 
     def add_model(self, model, initial=None, model_context=None):
-        """ Extends `transitions.core.Machine.add_model` by `model_context` keyword.
+        """Extends `transitions.core.Machine.add_model` by `model_context` keyword.
         Args:
             model (list or object): A model (list) to be managed by the machine.
             initial (str, Enum or State): The initial state of the passed model[s].
@@ -154,7 +154,7 @@ def add_model(self, model, initial=None, model_context=None):
             self.model_context_map[id(mod)].extend(model_context)
 
     def remove_model(self, model):
-        """ Extends `transitions.core.Machine.remove_model` by removing model specific context maps
+        """Extends `transitions.core.Machine.remove_model` by removing model specific context maps
             from the machine when the model itself is removed. """
         models = listify(model)
 
diff --git a/transitions/extensions/markup.py b/transitions/extensions/markup.py
index 0e4d3f42..7d5e1bdf 100644
--- a/transitions/extensions/markup.py
+++ b/transitions/extensions/markup.py
@@ -21,17 +21,17 @@
     # If enum is not available, create dummy classes for type checks
     # typing must be prevent redefinition issues with mypy
     class Enum:  # type:ignore
-        """ This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support."""
 
     class EnumMeta:  # type:ignore
-        """ This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support."""
 
 from ..core import Machine
 from .nesting import HierarchicalMachine
 
 
 class MarkupMachine(Machine):
-    """ Extends transitions.core.Machine with the capability to generate a dictionary representation of itself,
+    """Extends transitions.core.Machine with the capability to generate a dictionary representation of itself,
     its events, states and models.
     """
 
@@ -75,18 +75,18 @@ def __init__(self, model=Machine.self_literal, states=None, initial='initial', t
 
     @property
     def auto_transitions_markup(self):
-        """ Whether auto transitions should be included in the markup. """
+        """Whether auto transitions should be included in the markup."""
         return self._auto_transitions_markup
 
     @auto_transitions_markup.setter
     def auto_transitions_markup(self, value):
-        """ Whether auto transitions should be included in the markup. """
+        """Whether auto transitions should be included in the markup."""
         self._auto_transitions_markup = value
         self._needs_update = True
 
     @property
     def markup(self):
-        """ Returns the machine's configuration as a markup dictionary.
+        """Returns the machine's configuration as a markup dictionary.
         Returns:
             dict of machine configuration parameters.
         """
@@ -96,7 +96,7 @@ def markup(self):
     # the only reason why this not part of markup property is that pickle
     # has issues with properties during __setattr__ (self.markup is not set)
     def get_markup_config(self):
-        """ Generates and returns all machine markup parameters except models.
+        """Generates and returns all machine markup parameters except models.
         Returns:
             dict of machine configuration parameters.
         """
@@ -122,7 +122,7 @@ def add_states(self, states, on_enter=None, on_exit=None, ignore_invalid_trigger
 
     @staticmethod
     def format_references(func):
-        """ Creates a string representation of referenced callbacks.
+        """Creates a string representation of referenced callbacks.
         Returns:
             str that represents a callback reference.
         """
@@ -224,11 +224,11 @@ def _identify_callback(self, name):
 
 
 class HierarchicalMarkupMachine(MarkupMachine, HierarchicalMachine):
-    """ Extends transitions.extensions.nesting.HierarchicalMachine with markup capabilities. """
+    """Extends transitions.extensions.nesting.HierarchicalMachine with markup capabilities."""
 
 
 def rep(func, format_references=None):
-    """ Return a string representation for `func`. """
+    """Return a string representation for `func`."""
     if isinstance(func, string_types):
         return func
     if isinstance(func, numbers.Number):
diff --git a/transitions/extensions/nesting.py b/transitions/extensions/nesting.py
index 7c5e8408..d8c54ef7 100644
--- a/transitions/extensions/nesting.py
+++ b/transitions/extensions/nesting.py
@@ -19,10 +19,10 @@
 except ImportError:  # pragma: no cover
     # If enum is not available, create dummy classes for type checks
     class Enum:  # type: ignore
-        """ This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an Enum stub for Python 2 and Python 3.3 and before without Enum support."""
 
     class EnumMeta:  # type: ignore
-        """ This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support. """
+        """This is just an EnumMeta stub for Python 2 and Python 3.3 and before without Enum support."""
 
 from six import string_types
 
@@ -45,7 +45,7 @@ def _build_state_list(state_tree, separator, prefix=None):
 
 
 def resolve_order(state_tree):
-    """ Converts a (model) state tree into a list of state paths. States are ordered in the way in which states
+    """Converts a (model) state tree into a list of state paths. States are ordered in the way in which states
     should be visited to process the event correctly (Breadth-first). This makes sure that ALL children are evaluated
     before parents in parallel states.
     Args:
@@ -69,7 +69,7 @@ def resolve_order(state_tree):
 
 
 class FunctionWrapper(object):
-    """ A wrapper to enable transitions' convenience function to_<state> for nested states.
+    """A wrapper to enable transitions' convenience function to_<state> for nested states.
         This allows to call model.to_A.s1.C() in case a custom separator has been chosen."""
     def __init__(self, func):
         """
@@ -80,7 +80,7 @@ def __init__(self, func):
         self._func = func
 
     def add(self, func, path):
-        """ Assigns a `FunctionWrapper` as an attribute named like the next segment of the substates
+        """Assigns a `FunctionWrapper` as an attribute named like the next segment of the substates
             path.
         Args:
             func (callable): Function to be called at the end of the path.
@@ -100,7 +100,7 @@ def __call__(self, *args, **kwargs):
 
 
 class NestedEvent(Event):
-    """ An event type to work with nested states.
+    """An event type to work with nested states.
         This subclass is NOT compatible with simple Machine instances.
     """
 
@@ -108,7 +108,7 @@ def trigger(self, model, *args, **kwargs):
         raise RuntimeError("NestedEvent.trigger must not be called directly. Call Machine.trigger_event instead.")
 
     def trigger_nested(self, event_data):
-        """ Executes all transitions that match the current state,
+        """Executes all transitions that match the current state,
         halting as soon as one successfully completes.
         It is up to the machine's configuration of the Event whether processing happens queued (sequentially) or
         whether further Events are processed as they occur. NOTE: This should only
@@ -151,7 +151,7 @@ def _process(self, event_data):
 
 
 class NestedEventData(EventData):
-    """ Collection of relevant data related to the ongoing nested transition attempt. """
+    """Collection of relevant data related to the ongoing nested transition attempt."""
 
     def __init__(self, state, event, machine, model, args, kwargs):
         super(NestedEventData, self).__init__(state, event, machine, model, args, kwargs)
@@ -160,7 +160,7 @@ def __init__(self, state, event, machine, model, args, kwargs):
 
 
 class NestedState(State):
-    """ A state which allows substates.
+    """A state which allows substates.
     Attributes:
         states (OrderedDict): A list of substates of the current state.
         events (dict): A list of events defined for the nested state.
@@ -183,14 +183,14 @@ def __init__(self, name, on_enter=None, on_exit=None, ignore_invalid_triggers=No
         self._scope = []
 
     def add_substate(self, state):
-        """ Adds a state as a substate.
+        """Adds a state as a substate.
         Args:
             state (NestedState): State to add to the current state.
         """
         self.add_substates(state)
 
     def add_substates(self, states):
-        """ Adds a list of states to the current state.
+        """Adds a list of states to the current state.
         Args:
             states (list): List of state to add to the current state.
         """
@@ -198,7 +198,7 @@ def add_substates(self, states):
             self.states[state.name] = state
 
     def scoped_enter(self, event_data, scope=None):
-        """ Enters a state with the provided scope.
+        """Enters a state with the provided scope.
         Args:
             event_data (NestedEventData): The currently processed event.
             scope (list(str)): Names of the state's parents starting with the top most parent.
@@ -210,7 +210,7 @@ def scoped_enter(self, event_data, scope=None):
             self._scope = []
 
     def scoped_exit(self, event_data, scope=None):
-        """ Exits a state with the provided scope.
+        """Exits a state with the provided scope.
         Args:
             event_data (NestedEventData): The currently processed event.
             scope (list(str)): Names of the state's parents starting with the top most parent.
@@ -227,7 +227,7 @@ def name(self):
 
 
 class NestedTransition(Transition):
-    """ A transition which handles entering and leaving nested states. """
+    """A transition which handles entering and leaving nested states."""
 
     def _resolve_transition(self, event_data):
         dst_name_path = self.dest.split(event_data.machine.state_cls.separator)
@@ -342,7 +342,7 @@ def __deepcopy__(self, memo):
 
 
 class HierarchicalMachine(Machine):
-    """ Extends transitions.core.Machine by capabilities to handle nested states.
+    """Extends transitions.core.Machine by capabilities to handle nested states.
         A hierarchical machine REQUIRES NestedStates, NestedEvent and NestedTransitions
         (or any subclass of it) to operate.
     """
@@ -399,7 +399,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
         self.scoped, self.states, self.events, self.prefix_path = self._stack.pop()
 
     def add_model(self, model, initial=None):
-        """ Extends transitions.core.Machine.add_model by applying a custom 'to' function to
+        """Extends transitions.core.Machine.add_model by applying a custom 'to' function to
             the added model.
         """
         models = [self if mod is self.self_literal else mod for mod in listify(model)]
@@ -424,7 +424,7 @@ def add_model(self, model, initial=None):
 
     @property
     def initial(self):
-        """ Return the initial state. """
+        """Return the initial state."""
         return self._initial
 
     @initial.setter
@@ -444,7 +444,7 @@ def add_ordered_transitions(self, states=None, trigger='next_state',
                                                                  prepare=prepare, **kwargs)
 
     def add_states(self, states, on_enter=None, on_exit=None, ignore_invalid_triggers=None, **kwargs):
-        """ Add new nested state(s).
+        """Add new nested state(s).
         Args:
             states (list, str, dict, Enum, NestedState or HierarchicalMachine): a list, a NestedState instance, the
                 name of a new state, an enumeration (member) or a dict with keywords to pass on to the
@@ -506,7 +506,7 @@ def add_transition(self, trigger, source, dest, conditions=None,
                                                         unless, before, after, prepare, **kwargs)
 
     def get_global_name(self, state=None, join=True):
-        """ Returns the name of the passed state in context of the current prefix/scope.
+        """Returns the name of the passed state in context of the current prefix/scope.
         Args:
             state (str, Enum or NestedState): The state to be analyzed.
             join (bool): Whether this method should join the path elements or not
@@ -523,7 +523,7 @@ def get_global_name(self, state=None, join=True):
         return self.state_cls.separator.join(domains) if join else domains
 
     def get_nested_state_names(self):
-        """ Returns a list of global names of all states of a machine.
+        """Returns a list of global names of all states of a machine.
         Returns:
             list(str) of global state names.
         """
@@ -535,7 +535,7 @@ def get_nested_state_names(self):
         return ordered_states
 
     def get_nested_transitions(self, trigger="", src_path=None, dest_path=None):
-        """ Retrieves a list of all transitions matching the passed requirements.
+        """Retrieves a list of all transitions matching the passed requirements.
         Args:
             trigger (str): If set, return only transitions related to this trigger.
             src_path (list(str)): If set, return only transitions with this source state.
@@ -572,7 +572,7 @@ def get_nested_transitions(self, trigger="", src_path=None, dest_path=None):
         return transitions
 
     def get_nested_triggers(self, src_path=None):
-        """ Retrieves a list of valid triggers.
+        """Retrieves a list of valid triggers.
         Args:
             src_path (list(str)): A list representation of the source state's name.
         Returns:
@@ -591,7 +591,7 @@ def get_nested_triggers(self, src_path=None):
         return triggers
 
     def get_state(self, state, hint=None):
-        """ Return the State instance with the passed name.
+        """Return the State instance with the passed name.
         Args:
             state (str, Enum or list(str)): A state name, enum or state path
             hint (list(str)): A state path to check for the state in question
@@ -626,7 +626,7 @@ def get_state(self, state, hint=None):
         return self.states[state[0]]
 
     def get_states(self, states):
-        """ Retrieves a list of NestedStates.
+        """Retrieves a list of NestedStates.
         Args:
             states (str, Enum or list of str or Enum): Names/values of the states to retrieve.
         Returns:
@@ -641,7 +641,7 @@ def get_states(self, states):
         return res
 
     def get_transitions(self, trigger="", source="*", dest="*", delegate=False):
-        """ Return the transitions from the Machine.
+        """Return the transitions from the Machine.
         Args:
             trigger (str): Trigger name of the transition.
             source (str, State or Enum): Limits list to transitions from a certain state.
@@ -700,7 +700,7 @@ def _can_trigger_nested(self, model, trigger, path, *args, **kwargs):
         return False
 
     def get_triggers(self, *args):
-        """ Extends transitions.core.Machine.get_triggers to also include parent state triggers. """
+        """Extends transitions.core.Machine.get_triggers to also include parent state triggers."""
         triggers = []
         with self():
             for state in args:
@@ -716,7 +716,7 @@ def get_triggers(self, *args):
         return triggers
 
     def has_trigger(self, trigger, state=None):
-        """ Check whether an event/trigger is known to the machine
+        """Check whether an event/trigger is known to the machine
         Args:
             trigger (str): Event/trigger name
             state (optional[NestedState]): Limits the recursive search to this state and its children
@@ -738,7 +738,7 @@ def is_state(self, state, model, allow_substates=False):
         return getattr(model, self.model_attribute) == state
 
     def on_enter(self, state_name, callback):
-        """ Helper function to add callbacks to states in case a custom state separator is used.
+        """Helper function to add callbacks to states in case a custom state separator is used.
         Args:
             state_name (str): Name of the state
             callback (str or callable): Function to be called. Strings will be resolved to model functions.
@@ -746,7 +746,7 @@ def on_enter(self, state_name, callback):
         self.get_state(state_name).add_callback('enter', callback)
 
     def on_exit(self, state_name, callback):
-        """ Helper function to add callbacks to states in case a custom state separator is used.
+        """Helper function to add callbacks to states in case a custom state separator is used.
         Args:
             state_name (str): Name of the state
             callback (str or callable): Function to be called. Strings will be resolved to model functions.
@@ -754,7 +754,7 @@ def on_exit(self, state_name, callback):
         self.get_state(state_name).add_callback('exit', callback)
 
     def set_state(self, state, model=None):
-        """ Set the current state.
+        """Set the current state.
         Args:
             state (list of str or Enum or State): value of state(s) to be set
             model (optional[object]): targeted model; if not set, all models will be set to 'state'
@@ -765,7 +765,7 @@ def set_state(self, state, model=None):
             setattr(mod, self.model_attribute, values if len(values) > 1 else values[0])
 
     def to_state(self, model, state_name, *args, **kwargs):
-        """ Helper function to add go to states in case a custom state separator is used.
+        """Helper function to add go to states in case a custom state separator is used.
         Args:
             model (class): The model that should be used.
             state_name (str): Name of the destination state.
@@ -786,7 +786,7 @@ def to_state(self, model, state_name, *args, **kwargs):
         self._create_transition(event.source_name, state_name).execute(event)
 
     def trigger_event(self, model, trigger, *args, **kwargs):
-        """ Processes events recursively and forwards arguments if suitable events are found.
+        """Processes events recursively and forwards arguments if suitable events are found.
         This function is usually bound to models with model and trigger arguments already
         resolved as a partial. Execution will halt when a nested transition has been executed
         successfully.
@@ -946,7 +946,7 @@ def _add_trigger_to_model(self, trigger, model):
             self._checked_assignment(model, trigger, trig_func)
 
     def build_state_tree(self, model_states, separator, tree=None):
-        """ Converts a list of current states into a hierarchical state tree.
+        """Converts a list of current states into a hierarchical state tree.
         Args:
             model_states (str or list(str)):
             separator (str): The character used to separate state names
@@ -1026,7 +1026,7 @@ def _get_trigger(self, model, trigger_name, *args, **kwargs):
         return self.trigger_event(model, trigger_name, *args, **kwargs)
 
     def _has_state(self, state, raise_error=False):
-        """ This function
+        """This function
         Args:
             state (NestedState): state to be tested
             raise_error (bool): whether ValueError should be raised when the state
diff --git a/transitions/extensions/states.py b/transitions/extensions/states.py
index f6dd3a5b..b52f308e 100644
--- a/transitions/extensions/states.py
+++ b/transitions/extensions/states.py
@@ -17,7 +17,7 @@
 
 
 class Tags(State):
-    """ Allows states to be tagged.
+    """Allows states to be tagged.
         Attributes:
             tags (list): A list of tag strings. `State.is_<tag>` may be used
                 to check if <tag> is in the list.
@@ -37,7 +37,7 @@ def __getattr__(self, item):
 
 
 class Error(Tags):
-    """ This mix in builds upon tag and should be used INSTEAD of Tags if final states that have
+    """This mix in builds upon tag and should be used INSTEAD of Tags if final states that have
         not been tagged with 'accepted' should throw an `MachineError`.
     """
 
@@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs):
         super(Error, self).__init__(*args, **kwargs)
 
     def enter(self, event_data):
-        """ Extends transitions.core.State.enter. Throws a `MachineError` if there is
+        """Extends transitions.core.State.enter. Throws a `MachineError` if there is
             no leaving transition from this state and 'accepted' is not in self.tags.
         """
         if not event_data.machine.get_triggers(self.name) and not self.is_accepted:
@@ -64,7 +64,7 @@ def enter(self, event_data):
 
 
 class Timeout(State):
-    """ Adds timeout functionality to a state. Timeouts are handled model-specific.
+    """Adds timeout functionality to a state. Timeouts are handled model-specific.
     Attributes:
         timeout (float): Seconds after which a timeout function should be called.
         on_timeout (list): Functions to call when a timeout is triggered.
@@ -92,7 +92,7 @@ def __init__(self, *args, **kwargs):
         super(Timeout, self).__init__(*args, **kwargs)
 
     def enter(self, event_data):
-        """ Extends `transitions.core.State.enter` by starting a timeout timer for the current model
+        """Extends `transitions.core.State.enter` by starting a timeout timer for the current model
             when the state is entered and self.timeout is larger than 0.
         """
         if self.timeout > 0:
@@ -103,7 +103,7 @@ def enter(self, event_data):
         return super(Timeout, self).enter(event_data)
 
     def exit(self, event_data):
-        """ Extends `transitions.core.State.exit` by canceling a timer for the current model. """
+        """Extends `transitions.core.State.exit` by canceling a timer for the current model."""
         timer = self.runner.get(id(event_data.model), None)
         if timer is not None and timer.is_alive():
             timer.cancel()
@@ -117,17 +117,17 @@ def _process_timeout(self, event_data):
 
     @property
     def on_timeout(self):
-        """ List of strings and callables to be called when the state timeouts. """
+        """List of strings and callables to be called when the state timeouts."""
         return self._on_timeout
 
     @on_timeout.setter
     def on_timeout(self, value):
-        """ Listifies passed values and assigns them to on_timeout."""
+        """Listifies passed values and assigns them to on_timeout."""
         self._on_timeout = listify(value)
 
 
 class Volatile(State):
-    """ Adds scopes/temporal variables to the otherwise persistent state objects.
+    """Adds scopes/temporal variables to the otherwise persistent state objects.
     Attributes:
         volatile_cls (cls): Class of the temporal object to be initiated.
         volatile_hook (str): Model attribute name which will contain the volatile instance.
@@ -148,13 +148,13 @@ def __init__(self, *args, **kwargs):
         self.initialized = True
 
     def enter(self, event_data):
-        """ Extends `transitions.core.State.enter` by creating a volatile object and assign it to
+        """Extends `transitions.core.State.enter` by creating a volatile object and assign it to
             the current model's hook. """
         setattr(event_data.model, self.volatile_hook, self.volatile_cls())
         super(Volatile, self).enter(event_data)
 
     def exit(self, event_data):
-        """ Extends `transitions.core.State.exit` by deleting the temporal object from the model. """
+        """Extends `transitions.core.State.exit` by deleting the temporal object from the model."""
         super(Volatile, self).exit(event_data)
         try:
             delattr(event_data.model, self.volatile_hook)
@@ -163,7 +163,7 @@ def exit(self, event_data):
 
 
 class Retry(State):
-    """ The Retry mix-in sets a limit on the number of times a state may be
+    """The Retry mix-in sets a limit on the number of times a state may be
         re-entered from itself.
 
         The first time a state is entered it does not count as a retry. Thus with
@@ -224,11 +224,11 @@ def enter(self, event_data):
 
 
 def add_state_features(*args):
-    """ State feature decorator. Should be used in conjunction with a custom Machine class. """
+    """State feature decorator. Should be used in conjunction with a custom Machine class."""
     def _class_decorator(cls):
 
         class CustomState(type('CustomState', args, {}), cls.state_cls):
-            """ The decorated State. It is based on the State class used by the decorated Machine. """
+            """The decorated State. It is based on the State class used by the decorated Machine."""
 
         method_list = sum([c.dynamic_methods for c in inspect.getmro(CustomState) if hasattr(c, 'dynamic_methods')], [])
         CustomState.dynamic_methods = list(set(method_list))
@@ -238,4 +238,4 @@ class CustomState(type('CustomState', args, {}), cls.state_cls):
 
 
 class VolatileObject(object):
-    """ Empty Python object which can be used to assign attributes to."""
+    """Empty Python object which can be used to assign attributes to."""
diff --git a/transitions/version.py b/transitions/version.py
index 18980104..b148aa4d 100644
--- a/transitions/version.py
+++ b/transitions/version.py
@@ -1,4 +1,4 @@
-""" Contains the current version of transition which is used in setup.py and can also be used
+"""Contains the current version of transition which is used in setup.py and can also be used
     to determine transitions' version during runtime.
 """
 


Test patch:
diff --git a/conftest.py b/conftest.py
index 6f3d7493..ce4da0ee 100644
--- a/conftest.py
+++ b/conftest.py
@@ -16,7 +16,7 @@
 
 
 def pytest_ignore_collect(path):
-    """ Text collection function executed by pytest"""
+    """Text collection function executed by pytest"""
     if not WITH_ASYNC and basename(str(path)) in async_files:
         return True
     return False