Skip to content

Commit adbbedf

Browse files
committed
ruff formatting
1 parent 441e026 commit adbbedf

30 files changed

+650
-517
lines changed

aioetherscan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from aioetherscan.client import Client
1+
from aioetherscan.client import Client # noqa: F401

aioetherscan/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@
1919

2020

2121
class Client:
22-
def __init__(self, api_key: str, api_kind: str = 'eth', network: str = 'main',
23-
loop: AbstractEventLoop = None, timeout: ClientTimeout = None, proxy: str = None,
24-
throttler: AsyncContextManager = None, retry_options: RetryOptionsBase = None) -> None:
22+
def __init__(
23+
self,
24+
api_key: str,
25+
api_kind: str = 'eth',
26+
network: str = 'main',
27+
loop: AbstractEventLoop = None,
28+
timeout: ClientTimeout = None,
29+
proxy: str = None,
30+
throttler: AsyncContextManager = None,
31+
retry_options: RetryOptionsBase = None,
32+
) -> None:
2533
self._url_builder = UrlBuilder(api_key, api_kind, network)
2634
self._http = Network(self._url_builder, loop, timeout, proxy, throttler, retry_options)
2735

aioetherscan/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check_tag(tag: Union[str, int]) -> str:
2323
_TAGS = (
2424
'earliest', # the earliest/genesis block
2525
'latest', # the latest mined block
26-
'pending' # for the pending state/transactions
26+
'pending', # for the pending state/transactions
2727
)
2828

2929
if tag in _TAGS:
@@ -34,23 +34,23 @@ def check_tag(tag: Union[str, int]) -> str:
3434
def check_sort_direction(sort: str) -> str:
3535
_SORT_ORDERS = (
3636
'asc', # ascending order
37-
'desc' # descending order
37+
'desc', # descending order
3838
)
3939
return check_value(sort, _SORT_ORDERS)
4040

4141

4242
def check_blocktype(blocktype: str) -> str:
4343
_BLOCK_TYPES = (
4444
'blocks', # full blocks only
45-
'uncles' # uncle blocks only
45+
'uncles', # uncle blocks only
4646
)
4747
return check_value(blocktype, _BLOCK_TYPES)
4848

4949

5050
def check_closest_value(closest_value: str) -> str:
5151
_CLOSEST_VALUES = (
5252
'before', # ascending order
53-
'after' # descending order
53+
'after', # descending order
5454
)
5555

5656
return check_value(closest_value, _CLOSEST_VALUES)
@@ -90,5 +90,5 @@ def get_daily_stats_params(action: str, start_date: date, end_date: date, sort:
9090
action=action,
9191
startdate=start_date.isoformat(),
9292
enddate=end_date.isoformat(),
93-
sort=check_sort_direction(sort)
93+
sort=check_sort_direction(sort),
9494
)

aioetherscan/modules/account.py

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from typing import Iterable, Optional, List, Dict
22

3-
from aioetherscan.common import check_tag, check_sort_direction, check_blocktype, check_token_standard
3+
from aioetherscan.common import (
4+
check_tag,
5+
check_sort_direction,
6+
check_blocktype,
7+
check_token_standard,
8+
)
49
from aioetherscan.modules.base import BaseModule
510

611

@@ -16,28 +21,22 @@ def _module(self) -> str:
1621

1722
async def balance(self, address: str, tag: str = 'latest') -> str:
1823
"""Get Ether Balance for a single Address."""
19-
return await self._get(
20-
action='balance',
21-
address=address,
22-
tag=check_tag(tag)
23-
)
24+
return await self._get(action='balance', address=address, tag=check_tag(tag))
2425

2526
async def balances(self, addresses: Iterable[str], tag: str = 'latest') -> List[Dict]:
2627
"""Get Ether Balance for multiple Addresses in a single call."""
2728
return await self._get(
28-
action='balancemulti',
29-
address=','.join(addresses),
30-
tag=check_tag(tag)
29+
action='balancemulti', address=','.join(addresses), tag=check_tag(tag)
3130
)
3231

3332
async def normal_txs(
34-
self,
35-
address: str,
36-
start_block: Optional[int] = None,
37-
end_block: Optional[int] = None,
38-
sort: Optional[str] = None,
39-
page: Optional[int] = None,
40-
offset: Optional[int] = None
33+
self,
34+
address: str,
35+
start_block: Optional[int] = None,
36+
end_block: Optional[int] = None,
37+
sort: Optional[str] = None,
38+
page: Optional[int] = None,
39+
offset: Optional[int] = None,
4140
) -> List[Dict]:
4241
"""Get a list of 'Normal' Transactions By Address."""
4342
return await self._get(
@@ -47,18 +46,18 @@ async def normal_txs(
4746
endblock=end_block,
4847
sort=check_sort_direction(sort),
4948
page=page,
50-
offset=offset
49+
offset=offset,
5150
)
5251

5352
async def internal_txs(
54-
self,
55-
address: str,
56-
start_block: Optional[int] = None,
57-
end_block: Optional[int] = None,
58-
sort: Optional[str] = None,
59-
page: Optional[int] = None,
60-
offset: Optional[int] = None,
61-
txhash: Optional[str] = None
53+
self,
54+
address: str,
55+
start_block: Optional[int] = None,
56+
end_block: Optional[int] = None,
57+
sort: Optional[str] = None,
58+
page: Optional[int] = None,
59+
offset: Optional[int] = None,
60+
txhash: Optional[str] = None,
6261
) -> List[Dict]:
6362
"""Get a list of 'Internal' Transactions by Address or Transaction Hash."""
6463
return await self._get(
@@ -69,30 +68,26 @@ async def internal_txs(
6968
sort=check_sort_direction(sort),
7069
page=page,
7170
offset=offset,
72-
txhash=txhash
71+
txhash=txhash,
7372
)
7473

7574
async def token_transfers(
76-
self,
77-
address: Optional[str] = None,
78-
contract_address: Optional[str] = None,
79-
start_block: Optional[int] = None,
80-
end_block: Optional[int] = None,
81-
sort: Optional[str] = None,
82-
page: Optional[int] = None,
83-
offset: Optional[int] = None,
84-
token_standard: str = 'erc20'
75+
self,
76+
address: Optional[str] = None,
77+
contract_address: Optional[str] = None,
78+
start_block: Optional[int] = None,
79+
end_block: Optional[int] = None,
80+
sort: Optional[str] = None,
81+
page: Optional[int] = None,
82+
offset: Optional[int] = None,
83+
token_standard: str = 'erc20',
8584
) -> List[Dict]:
8685
"""Get a list of "ERC20 - Token Transfer Events" by Address"""
8786
if not address and not contract_address:
8887
raise ValueError('At least one of address or contract_address must be specified.')
8988

9089
token_standard = check_token_standard(token_standard)
91-
actions = dict(
92-
erc20='tokentx',
93-
erc721='tokennfttx',
94-
erc1155='token1155tx'
95-
)
90+
actions = dict(erc20='tokentx', erc721='tokennfttx', erc1155='token1155tx')
9691

9792
return await self._get(
9893
action=actions.get(token_standard),
@@ -102,36 +97,35 @@ async def token_transfers(
10297
sort=check_sort_direction(sort),
10398
page=page,
10499
offset=offset,
105-
contractaddress=contract_address
100+
contractaddress=contract_address,
106101
)
107102

108103
async def mined_blocks(
109-
self,
110-
address: str,
111-
blocktype: str = 'blocks',
112-
page: Optional[int] = None,
113-
offset: Optional[int] = None
104+
self,
105+
address: str,
106+
blocktype: str = 'blocks',
107+
page: Optional[int] = None,
108+
offset: Optional[int] = None,
114109
) -> List:
115110
"""Get list of Blocks Validated by Address"""
116111
return await self._get(
117112
action='getminedblocks',
118113
address=address,
119114
blocktype=check_blocktype(blocktype),
120115
page=page,
121-
offset=offset
116+
offset=offset,
122117
)
123118

124119
async def beacon_chain_withdrawals(
125-
self,
126-
address: str,
127-
start_block: Optional[int] = None,
128-
end_block: Optional[int] = None,
129-
sort: Optional[str] = None,
130-
page: Optional[int] = None,
131-
offset: Optional[int] = None,
120+
self,
121+
address: str,
122+
start_block: Optional[int] = None,
123+
end_block: Optional[int] = None,
124+
sort: Optional[str] = None,
125+
page: Optional[int] = None,
126+
offset: Optional[int] = None,
132127
) -> List[Dict]:
133128
"""Get Beacon Chain Withdrawals by Address and Block Range"""
134-
# todo: refactor
135129
return await self._get(
136130
action='txsBeaconWithdrawal',
137131
address=address,
@@ -145,8 +139,5 @@ async def beacon_chain_withdrawals(
145139
async def account_balance_by_blockno(self, address: str, blockno: int) -> str:
146140
"""Get Historical Ether Balance for a Single Address By BlockNo"""
147141
return await self._get(
148-
module='account',
149-
action='balancehistory',
150-
address=address,
151-
blockno=blockno
142+
module='account', action='balancehistory', address=address, blockno=blockno
152143
)

aioetherscan/modules/block.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,54 @@ def _module(self) -> str:
1717

1818
async def block_reward(self, blockno: int) -> Dict:
1919
"""Get Block And Uncle Rewards by BlockNo"""
20-
return await self._get(
21-
action='getblockreward',
22-
blockno=blockno
23-
)
20+
return await self._get(action='getblockreward', blockno=blockno)
2421

2522
async def est_block_countdown_time(self, blockno: int) -> Dict:
2623
"""Get Estimated Block Countdown Time by BlockNo"""
27-
return await self._get(
28-
action='getblockcountdown',
29-
blockno=blockno
30-
)
24+
return await self._get(action='getblockcountdown', blockno=blockno)
3125

3226
async def block_number_by_ts(self, ts: int, closest: str) -> Dict:
3327
"""Get Block Number by Timestamp"""
3428
return await self._get(
35-
action='getblocknobytime',
36-
timestamp=ts,
37-
closest=check_closest_value(closest)
29+
action='getblocknobytime', timestamp=ts, closest=check_closest_value(closest)
3830
)
3931

40-
async def daily_average_block_size(self, start_date: date, end_date: date, sort: Optional[str] = None) -> Dict:
32+
async def daily_average_block_size(
33+
self, start_date: date, end_date: date, sort: Optional[str] = None
34+
) -> Dict:
4135
"""Get Daily Average Block Size"""
42-
return await self._get(**get_daily_stats_params('dailyavgblocksize', start_date, end_date, sort))
36+
return await self._get(
37+
**get_daily_stats_params('dailyavgblocksize', start_date, end_date, sort)
38+
)
4339

44-
async def daily_block_count(self, start_date: date, end_date: date, sort: Optional[str] = None) -> Dict:
40+
async def daily_block_count(
41+
self, start_date: date, end_date: date, sort: Optional[str] = None
42+
) -> Dict:
4543
"""Get Daily Block Count and Rewards"""
46-
return await self._get(**get_daily_stats_params('dailyblkcount', start_date, end_date, sort))
44+
return await self._get(
45+
**get_daily_stats_params('dailyblkcount', start_date, end_date, sort)
46+
)
4747

48-
async def daily_block_rewards(self, start_date: date, end_date: date, sort: Optional[str] = None) -> Dict:
48+
async def daily_block_rewards(
49+
self, start_date: date, end_date: date, sort: Optional[str] = None
50+
) -> Dict:
4951
"""Get Daily Block Rewards"""
50-
return await self._get(**get_daily_stats_params('dailyblockrewards', start_date, end_date, sort))
52+
return await self._get(
53+
**get_daily_stats_params('dailyblockrewards', start_date, end_date, sort)
54+
)
5155

52-
async def daily_average_time_for_a_block(self, start_date: date, end_date: date,
53-
sort: Optional[str] = None) -> Dict:
56+
async def daily_average_time_for_a_block(
57+
self, start_date: date, end_date: date, sort: Optional[str] = None
58+
) -> Dict:
5459
"""Get Daily Average Time for A Block to be Included in the Ethereum Blockchain"""
55-
return await self._get(**get_daily_stats_params('dailyavgblocktime', start_date, end_date, sort))
60+
return await self._get(
61+
**get_daily_stats_params('dailyavgblocktime', start_date, end_date, sort)
62+
)
5663

57-
async def daily_uncle_block_count(self, start_date: date, end_date: date, sort: Optional[str] = None) -> Dict:
64+
async def daily_uncle_block_count(
65+
self, start_date: date, end_date: date, sort: Optional[str] = None
66+
) -> Dict:
5867
"""Get Daily Uncle Block Count and Rewards"""
59-
return await self._get(**get_daily_stats_params('dailyuncleblkcount', start_date, end_date, sort))
68+
return await self._get(
69+
**get_daily_stats_params('dailyuncleblkcount', start_date, end_date, sort)
70+
)

0 commit comments

Comments
 (0)