Skip to content

Commit f0f244f

Browse files
committed
fix: fixed typing
1 parent d0fc84a commit f0f244f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

uniswap/decorators.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import functools
2-
from typing import Callable, Any, List, TYPE_CHECKING, TypeVar
2+
from typing import Callable, List, TYPE_CHECKING, TypeVar, Optional
33
from typing_extensions import ParamSpec, Concatenate
44

5+
from .types import AddressLike
56
from .constants import ETH_ADDRESS
67

78
if TYPE_CHECKING:
@@ -13,15 +14,15 @@
1314

1415

1516
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]:
1819
"""Decorator to check if user is approved for a token. It approves them if they
1920
need to be approved."""
2021

2122
@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:
2324
# 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
2526
token_two = None
2627

2728
# Check second token, if needed
@@ -42,11 +43,11 @@ def approved(self: Any, *args: Any, **kwargs: Any) -> Any:
4243
def supports(
4344
versions: List[int],
4445
) -> Callable[
45-
[Callable[Concatenate[Uniswap, P], T]], Callable[Concatenate[Uniswap, P], T]
46+
[Callable[Concatenate["Uniswap", P], T]], Callable[Concatenate["Uniswap", P], T]
4647
]:
4748
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]:
5051
if f.__doc__ is None:
5152
f.__doc__ = ""
5253
f.__doc__ += """\n\n

uniswap/types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Union
2-
from web3.eth import Contract # noqa: F401
3-
from web3.types import Address, ChecksumAddress
2+
from eth_typing.evm import Address, ChecksumAddress
43

54

65
AddressLike = Union[Address, ChecksumAddress]

uniswap/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
from web3 import Web3
77
from web3.exceptions import NameNotFound
8+
from web3.contract import Contract
89

9-
from .types import AddressLike, Address, Contract
10+
from .types import AddressLike, Address
1011

1112

1213
def _str_to_addr(s: Union[AddressLike, str]) -> Address:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy