Skip to content

Commit d0384b9

Browse files
committed
Add black to web3/tools
1 parent ca1dbbd commit d0384b9

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ basepython=python
6464
extras=linter
6565
commands=
6666
flake8 {toxinidir}/web3 {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/tests --exclude {toxinidir}/ethpm/ethpm-spec
67-
black {toxinidir}/ethpm {toxinidir}/web3/auto {toxinidir}/web3/utils {toxinidir}/web3/_utils {toxinidir}/web3/beacon {toxinidir}/web3/gas_strategies {toxinidir}/web3/scripts {toxinidir}/web3/providers {toxinidir}/web3/middleware --exclude {toxinidir}/ethpm/ethpm-spec --check
67+
black {toxinidir}/ethpm {toxinidir}/web3/auto {toxinidir}/web3/utils {toxinidir}/web3/_utils {toxinidir}/web3/beacon {toxinidir}/web3/gas_strategies {toxinidir}/web3/scripts {toxinidir}/web3/providers {toxinidir}/web3/middleware {toxinidir}/web3/tools --exclude {toxinidir}/ethpm/ethpm-spec --check
6868
isort --recursive --check-only --diff {toxinidir}/web3/ {toxinidir}/ens/ {toxinidir}/ethpm/ {toxinidir}/tests/
6969
mypy -p web3 -p ethpm -p ens --config-file {toxinidir}/mypy.ini
7070

web3/tools/benchmark/main.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@
4848
Wei,
4949
)
5050

51-
KEYFILE_PW = 'web3py-test'
51+
KEYFILE_PW = "web3py-test"
5252

5353
parser = argparse.ArgumentParser()
5454
parser.add_argument(
55-
"--num-calls", type=int, default=10, help="The number of RPC calls to make",
55+
"--num-calls",
56+
type=int,
57+
default=10,
58+
help="The number of RPC calls to make",
5659
)
5760

5861
# TODO - layers to test:
@@ -65,7 +68,7 @@ def build_web3_http(endpoint_uri: str) -> Web3:
6568
wait_for_http(endpoint_uri)
6669
_w3 = Web3(
6770
HTTPProvider(endpoint_uri),
68-
middlewares=[gas_price_strategy_middleware, buffered_gas_estimate_middleware]
71+
middlewares=[gas_price_strategy_middleware, buffered_gas_estimate_middleware],
6972
)
7073
return _w3
7174

@@ -74,7 +77,10 @@ async def build_async_w3_http(endpoint_uri: str) -> Web3:
7477
await wait_for_aiohttp(endpoint_uri)
7578
_w3 = Web3(
7679
AsyncHTTPProvider(endpoint_uri), # type: ignore
77-
middlewares=[async_gas_price_strategy_middleware, async_buffered_gas_estimate_middleware],
80+
middlewares=[
81+
async_gas_price_strategy_middleware,
82+
async_buffered_gas_estimate_middleware,
83+
],
7884
modules={"eth": AsyncEth},
7985
)
8086
return _w3
@@ -121,7 +127,9 @@ def main(logger: logging.Logger, num_calls: int) -> None:
121127
for process in built_fixture:
122128
w3_http = build_web3_http(fixture.endpoint_uri)
123129
loop = asyncio.get_event_loop()
124-
async_w3_http = loop.run_until_complete(build_async_w3_http(fixture.endpoint_uri))
130+
async_w3_http = loop.run_until_complete(
131+
build_async_w3_http(fixture.endpoint_uri)
132+
)
125133
# TODO: swap out w3_http for the async_w3_http once GethPersonal module is async
126134
async_unlocked_acct = loop.run_until_complete(
127135
async_unlocked_account(w3_http, async_w3_http.eth)
@@ -137,16 +145,20 @@ def main(logger: logging.Logger, num_calls: int) -> None:
137145
{
138146
"name": "eth_sendTransaction",
139147
"params": {},
140-
"exec": lambda: w3_http.eth.send_transaction({
141-
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
142-
'from': unlocked_account(w3_http),
143-
'value': Wei(12345),
144-
}),
145-
"async_exec": lambda: async_w3_http.eth.send_transaction({
146-
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
147-
'from': async_unlocked_acct,
148-
'value': Wei(12345)
149-
}),
148+
"exec": lambda: w3_http.eth.send_transaction(
149+
{
150+
"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
151+
"from": unlocked_account(w3_http),
152+
"value": Wei(12345),
153+
}
154+
),
155+
"async_exec": lambda: async_w3_http.eth.send_transaction(
156+
{
157+
"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
158+
"from": async_unlocked_acct,
159+
"value": Wei(12345),
160+
}
161+
),
150162
},
151163
{
152164
"name": "eth_blockNumber",
@@ -165,7 +177,10 @@ def main(logger: logging.Logger, num_calls: int) -> None:
165177
def benchmark(method: Dict[str, Any]) -> None:
166178
outcomes: Dict[str, Union[str, float]] = defaultdict(lambda: "N/A")
167179
outcomes["name"] = method["name"]
168-
outcomes["HTTPProvider"] = sync_benchmark(method["exec"], num_calls,)
180+
outcomes["HTTPProvider"] = sync_benchmark(
181+
method["exec"],
182+
num_calls,
183+
)
169184
outcomes["AsyncHTTPProvider"] = loop.run_until_complete(
170185
async_benchmark(method["async_exec"], num_calls)
171186
)

web3/tools/benchmark/node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def _geth_process(
101101
str(genesis_file),
102102
)
103103
check_output(
104-
init_datadir_command, stdin=PIPE, stderr=PIPE,
104+
init_datadir_command,
105+
stdin=PIPE,
106+
stderr=PIPE,
105107
)
106108
proc = Popen(
107109
self._geth_command_arguments(datadir),

web3/tools/benchmark/reporting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def print_header(logger: Logger, num_calls: int) -> None:
2020
logger.info("-" * 112)
2121

2222

23-
def print_entry(logger: Logger, method_benchmarks: Dict[str, Any],) -> None:
23+
def print_entry(
24+
logger: Logger,
25+
method_benchmarks: Dict[str, Any],
26+
) -> None:
2427
logger.info(
2528
"|{:^26}|{:^20.10}|{:^20.10}|{:^20.10}|{:^20.10}|".format(
2629
method_benchmarks["name"],

web3/tools/pytest_ethereum/deployer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def __init__(self, package: Package) -> None:
3030
self.package = package
3131
self.strategies = {} # type: Dict[str, Callable[[Package], Package]]
3232

33-
def deploy(
34-
self, contract_type: ContractName, *args: Any, **kwargs: Any
35-
) -> Package:
33+
def deploy(self, contract_type: ContractName, *args: Any, **kwargs: Any) -> Package:
3634
factory = self.package.get_contract_factory(contract_type)
3735
if contract_type in self.strategies:
3836
strategy = self.strategies[contract_type]

web3/tools/pytest_ethereum/linker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def deploy(
5959

6060
@curry
6161
def _deploy(
62-
contract_name: ContractName, args: Any, transaction: Dict[str, Any], package: Package
62+
contract_name: ContractName,
63+
args: Any,
64+
transaction: Dict[str, Any],
65+
package: Package,
6366
) -> Package:
6467
# Deploy new instance
6568
factory = package.get_contract_factory(contract_name)

0 commit comments

Comments
 (0)