Skip to content

Commit

Permalink
Merge 489771a into bc5ef6e
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed Oct 7, 2019
2 parents bc5ef6e + 489771a commit 42ab6a6
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 16 deletions.
24 changes: 21 additions & 3 deletions deal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,34 @@
__license__ = 'MIT'


from ._aliases import * # noQA
from ._exceptions import * # noQA
# app
from ._aliases import chain, ensure, inv, invariant, offline, post, pre, pure, raises, require, safe, silent
from ._exceptions import * # noQA
from ._schemes import Scheme
from ._state import reset, switch
from ._testing import cases, TestCase
from ._testing import TestCase, cases


__all__ = [
'cases',
'reset',
'Scheme',
'switch',
'TestCase',

# decorators
'chain',
'ensure',
'inv',
'invariant',
'offline',
'post',
'pre',
'pure',
'raises',
'safe',
'silent',

# aliases
'require',
]
14 changes: 3 additions & 11 deletions deal/_aliases.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# built-in
from functools import partial
from typing import Callable

from ._decorators import Pre, Post, Invariant, Raises, Offline, Silent, Ensure
# app
from ._decorators import Ensure, Invariant, Offline, Post, Pre, Raises, Silent
from ._types import ExceptionType


__all__ = [
'require', 'pre',
'ensure', 'post',
'inv', 'invariant',
'raises', 'safe',
'offline', 'silent',
'chain', 'pure',
]


require = pre = Pre
post = Post
ensure = Ensure
Expand Down
1 change: 1 addition & 0 deletions deal/_decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from .ensure import Ensure
from .inv import Invariant
from .offline import Offline
Expand Down
2 changes: 2 additions & 0 deletions deal/_decorators/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# built-in
from functools import update_wrapper
from inspect import getcallargs
from typing import Callable, Type

# app
from .._exceptions import ContractError
from .._state import state
from .._types import ExceptionType
Expand Down
1 change: 1 addition & 0 deletions deal/_decorators/ensure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from .._exceptions import PostContractError
from .._types import ExceptionType
from .base import Base
Expand Down
2 changes: 2 additions & 0 deletions deal/_decorators/inv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# built-in
from functools import partial, update_wrapper
from types import MethodType
from typing import Callable

# app
from .._exceptions import InvContractError
from .._types import ExceptionType
from .base import Base
Expand Down
2 changes: 2 additions & 0 deletions deal/_decorators/offline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# built-in
import socket

# app
from .._exceptions import OfflineContractError
from .._types import ExceptionType
from .base import Base
Expand Down
1 change: 1 addition & 0 deletions deal/_decorators/post.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from .._exceptions import PostContractError
from .._types import ExceptionType
from .base import Base
Expand Down
1 change: 1 addition & 0 deletions deal/_decorators/pre.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from .._exceptions import PreContractError
from .._types import ExceptionType
from .base import Base
Expand Down
2 changes: 2 additions & 0 deletions deal/_decorators/raises.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# built-in
from typing import Tuple

# app
from .._exceptions import ContractError, RaisesContractError
from .._types import ExceptionType
from .base import Base
Expand Down
2 changes: 2 additions & 0 deletions deal/_decorators/silent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# built-in
import sys
from io import StringIO

# app
from .._exceptions import SilentContractError
from .._types import ExceptionType
from .base import Base
Expand Down
5 changes: 4 additions & 1 deletion deal/_testing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# built-in
import typing
from inspect import signature

# external
import hypothesis
import hypothesis.strategies
import typeguard

from ._decorators import Raises, Pre
# app
from ._decorators import Pre, Raises
from ._types import ArgsKwargsType, ExceptionType


Expand Down
3 changes: 2 additions & 1 deletion deal/_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Union, Type, Tuple, Any, Dict
# built-in
from typing import Any, Dict, Tuple, Type, Union


ExceptionType = Union[Exception, Type[Exception]]
Expand Down

0 comments on commit 42ab6a6

Please sign in to comment.