diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ac62f2320b0cdbd723562fc7b300eac1dd80005..2c8419626ab4da4f9801824637611879e2251c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,4 @@ # v2.14.41 + +* added `ExceptionList` +* added `terminate_on` for `TerminableThread` diff --git a/docs/coding/typing.rst b/docs/coding/typing.rst index d417848fc32254c47bd73855140e4b156a72e1e9..e57201923e551c1ac0f0ba5ad1f5e74c3c8a62da 100644 --- a/docs/coding/typing.rst +++ b/docs/coding/typing.rst @@ -16,6 +16,8 @@ They are as follows: * `Predicate` - a callable that accepts a `T` and returns a bool * `KVTuple` - a tuple of (K, V) * `Comparable` - a class that allows comparison between it's instances +* `ExceptionList` - either a single exception type or a tuple of exception types. + As used by `except` statement and some satella functions. You may use these generics in your classes, eg. diff --git a/satella/coding/typing.py b/satella/coding/typing.py index aa015eb4436debc2272c4bfbce920c2cd478b09c..ab81ef1ef2704095ff9e905488039bac75243bd6 100644 --- a/satella/coding/typing.py +++ b/satella/coding/typing.py @@ -1,6 +1,11 @@ import typing as tp from abc import ABCMeta, abstractmethod +__all__ = ['Iteratable', 'T', 'U', 'V', 'K', 'Number', 'ExceptionClassType', + 'NoArgCallable', 'Appendable', 'Predicate', 'KVTuple', + 'Comparable', 'ExceptionList'] + + NoneType = None.__class__ T = tp.TypeVar('T') Iteratable = tp.Union[tp.Iterator[T], tp.Iterable[T]] @@ -13,6 +18,7 @@ NoArgCallable = tp.Callable[[], T] Predicate = tp.Callable[[T], bool] ExceptionClassType = tp.Type[Exception] +ExceptionList = tp.Union[ExceptionClassType, tp.Tuple[ExceptionClassType]] class ClassComparable(metaclass=ABCMeta): @@ -42,6 +48,3 @@ class Appendable(Protocol[T]): ... -__all__ = ['Iteratable', 'T', 'U', 'V', 'K', 'Number', 'ExceptionClassType', - 'NoArgCallable', 'Appendable', 'Predicate', 'KVTuple', - 'Comparable']