rejects

Logical complement of the accepts
function, will raise a TypeError if
the passed in objects correspond to
the required types. For example, to
implement a grouping function that
forces the user to cover all possible
cases:

throws

This is good for debugging or development
when you want to make sure that your
function throws the given exceptions.

Single dispatch methods

In Python 3, the functools library
includes the singledispatch method,
which accepts an argspec and then makes
callables which, different ones can be
called based on their type. Using that
it’s possible to build PEP443-style
generic dispatched functions. For
example:

Keep in mind that single-dispatch
generic functions do come at a cost,
especially if they are done so at
runtime, unless you use a JIT like
PyPy. Also, they do not work with
the traits in promises since
the functions do not use isinstance
as a means of type checking.

If you need traits when dispatching
functions you can use the following
pattern:

The semantics are almost the same as
the standard library dispatch function
except for the fact that it can dispatch
according to a given argument instead of
the first argument, reducing the need
for arg-swapping helper functions.

Running the tests

You can also run the test suite for
the current version of the promises
library by running the command below: