1
1
import functools
2
- from typing import Callable , Any , List , TYPE_CHECKING , TypeVar
2
+ from typing import Callable , List , TYPE_CHECKING , TypeVar , Optional
3
3
from typing_extensions import ParamSpec , Concatenate
4
4
5
+ from .types import AddressLike
5
6
from .constants import ETH_ADDRESS
6
7
7
8
if TYPE_CHECKING :
13
14
14
15
15
16
def check_approval (
16
- method : Callable [Concatenate [Uniswap , P ], T ]
17
- ) -> Callable [Concatenate [Uniswap , P ], T ]:
17
+ method : Callable [Concatenate [" Uniswap" , P ], T ]
18
+ ) -> Callable [Concatenate [" Uniswap" , P ], T ]:
18
19
"""Decorator to check if user is approved for a token. It approves them if they
19
20
need to be approved."""
20
21
21
22
@functools .wraps (method )
22
- def approved (self : Any , * args : Any , ** kwargs : Any ) -> Any :
23
+ def approved (self : "Uniswap" , * args : P . args , ** kwargs : P . kwargs ) -> T :
23
24
# Check to see if the first token is actually ETH
24
- token = args [0 ] if args [0 ] != ETH_ADDRESS else None
25
+ token : Optional [ AddressLike ] = args [0 ] if args [0 ] != ETH_ADDRESS else None # type: ignore
25
26
token_two = None
26
27
27
28
# Check second token, if needed
@@ -42,11 +43,11 @@ def approved(self: Any, *args: Any, **kwargs: Any) -> Any:
42
43
def supports (
43
44
versions : List [int ],
44
45
) -> Callable [
45
- [Callable [Concatenate [Uniswap , P ], T ]], Callable [Concatenate [Uniswap , P ], T ]
46
+ [Callable [Concatenate [" Uniswap" , P ], T ]], Callable [Concatenate [" Uniswap" , P ], T ]
46
47
]:
47
48
def g (
48
- f : Callable [Concatenate [Uniswap , P ], T ]
49
- ) -> Callable [Concatenate [Uniswap , P ], T ]:
49
+ f : Callable [Concatenate [" Uniswap" , P ], T ]
50
+ ) -> Callable [Concatenate [" Uniswap" , P ], T ]:
50
51
if f .__doc__ is None :
51
52
f .__doc__ = ""
52
53
f .__doc__ += """\n \n
0 commit comments