11from __future__ import annotations
22
3- __all__ = ("ContractAware" , "ContractCheck" , "ContractManagerAware" ,)
3+ __all__ = (
4+ "ContractAware" ,
5+ "ContractCheck" ,
6+ "ContractManagerAware" ,
7+ )
48
59import abc
6- import typing
710import dataclasses
11+ import typing
12+
13+ from returns .io import IO
814
9- from .. import utils
15+ from multibar import utils
1016
1117
1218@dataclasses .dataclass
1319class ContractCheck :
1420 kept : bool
15- metadata : dict [ str , typing .Any ] = dataclasses .field (default_factory = dict )
21+ metadata : typing . MutableMapping [ typing . Any , typing .Any ] = dataclasses .field (default_factory = dict )
1622 warnings : list [str ] = dataclasses .field (default_factory = list )
1723 errors : list [str ] = dataclasses .field (default_factory = list )
1824
1925 @classmethod
2026 def done (
2127 cls ,
22- metadata : typing .Optional [dict [ str , typing .Any ]] = None ,
28+ metadata : typing .Optional [typing . MutableMapping [ typing . Any , typing .Any ]] = None ,
2329 ) -> ContractCheck :
2430 return cls (kept = True , metadata = utils .none_or ({}, metadata ))
2531
2632 @classmethod
33+ @typing .no_type_check
2734 def terminated (
2835 cls ,
29- metadata : typing .Optional [dict [ str , typing .Any ]] = None ,
36+ metadata : typing .Optional [typing . MutableMapping [ typing . Any , typing .Any ]] = None ,
3037 warnings : typing .Optional [list [str ]] = None ,
3138 errors : typing .Optional [list [str ]] = None ,
3239 ) -> ContractCheck :
@@ -46,15 +53,15 @@ def check(self, *args: typing.Any, **kwargs: typing.Any) -> ContractCheck:
4653 ...
4754
4855 @abc .abstractmethod
49- def render_terminated_contract (self , check : ContractCheck , / , * , raise_errors : bool ) -> None :
56+ def render_terminated_contract (self , check : ContractCheck , / , * , raise_errors : bool ) -> IO [ None ] :
5057 ...
5158
5259
5360class ContractManagerAware (abc .ABC ):
5461 __slots__ = ()
5562
5663 @abc .abstractmethod
57- def trigger_contract (
64+ def check_contract (
5865 self ,
5966 contract : ContractAware ,
6067 * args : typing .Any ,
@@ -63,7 +70,7 @@ def trigger_contract(
6370 ...
6471
6572 @abc .abstractmethod
66- def trigger_contracts (self , * args : typing .Any , ** kwargs : typing .Any ) -> None :
73+ def check_contracts (self , * args : typing .Any , ** kwargs : typing .Any ) -> None :
6774 ...
6875
6976 @abc .abstractmethod
0 commit comments