diff --git a/docs/contributing.rst b/docs/contributing.rst index 438011a3a9..0b459235ef 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -202,7 +202,7 @@ virtualenv for smoke testing: >>> ... -Verify the latest documentation +Verify the latest documentation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To preview the documentation that will get published: @@ -321,7 +321,7 @@ Parity/OpenEthereum fixtures .. code:: sh $ python /tests/integration/generate_fixtures/parity.py /tests/integration/parity-X.Y.Z-fixture - + 5. The output of this script is your fixture, a zip file. Store the fixture in the ``/tests/integration/`` directory and update the ``/tests/integration/parity/conftest.py`` file to point the new fixture. diff --git a/docs/examples.rst b/docs/examples.rst index 803952e33f..836fe50a0c 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -863,7 +863,7 @@ The script can be run with: ``python ./eventscanner.py `` because it cannot correctly throttle and decrease the `eth_getLogs` block number range. """ - def __init__(self, web3: Web3, contract: Contract, state: EventScannerState, events: List, filters: {}, + def __init__(self, w3: Web3, contract: Contract, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int = 10000, max_request_retries: int = 30, request_retry_seconds: float = 3.0): """ :param contract: Contract @@ -876,7 +876,7 @@ The script can be run with: ``python ./eventscanner.py `` self.logger = logger self.contract = contract - self.web3 = web3 + self.w3 = web3 self.state = state self.events = events self.filters = filters @@ -1356,7 +1356,7 @@ The script can be run with: ``python ./eventscanner.py `` # throttle down. provider.middlewares.clear() - web3 = Web3(provider) + w3 = Web3(provider) # Prepare stub ERC-20 contract object abi = json.loads(ABI) @@ -1366,7 +1366,7 @@ The script can be run with: ``python ./eventscanner.py `` state = JSONifiedState() state.restore() - # chain_id: int, web3: Web3, abi: dict, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int=10000 + # chain_id: int, w3: Web3, abi: dict, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int=10000 scanner = EventScanner( web3=web3, contract=ERC20, diff --git a/docs/v4_migration.rst b/docs/v4_migration.rst index 14ca20f2e1..739f0b17e2 100644 --- a/docs/v4_migration.rst +++ b/docs/v4_migration.rst @@ -91,9 +91,9 @@ These providers are fairly uncommon. If you don't recognize the names, you can probably skip the section. However, if you were using web3.py for testing contracts, -you might have been using TestRPCProvider or EthereumTesterProvider. +you might have been using TestRPCProvider or EthereumTesterProvider. -In v4 there is a new :class:`EthereumTesterProvider`, and the old v3 implementation has been +In v4 there is a new :class:`EthereumTesterProvider`, and the old v3 implementation has been removed. Web3.py v4 uses :class:`eth_tester.main.EthereumTester` under the hood, instead of eth-testrpc. While ``eth-tester`` is still in beta, many parts are already in better shape than testrpc, so we decided to replace it in v4. @@ -101,7 +101,7 @@ already in better shape than testrpc, so we decided to replace it in v4. If you were using TestRPC, or were explicitly importing EthereumTesterProvider, like: ``from web3.providers.tester import EthereumTesterProvider``, then you will need to update. -With v4 you should import with ``from web3 import EthereumTesterProvider``. As before, you'll +With v4 you should import with ``from web3 import EthereumTesterProvider``. As before, you'll need to install Web3.py with the ``tester`` extra to get these features, like: .. code-block:: bash diff --git a/docs/web3.beacon.rst b/docs/web3.beacon.rst index 957e924ab3..863a4510dd 100644 --- a/docs/web3.beacon.rst +++ b/docs/web3.beacon.rst @@ -241,7 +241,7 @@ Methods 'signature': '0x967dd2946358db7e426ed19d4576bc75123520ef6a489ca50002222070ee4611f9cef394e5e3071236a93b825f18a4ad07f1d5a1405e6c984f1d71e03f535d13a2156d6ba22cb0c2b148df23a7b8a7293315d6e74b9a26b64283e8393f2ad4c5' } ], - 'deposits': [], + 'deposits': [], 'voluntary_exits': [] } }, diff --git a/docs/web3.main.rst b/docs/web3.main.rst index 4d9ec25c36..455c306801 100644 --- a/docs/web3.main.rst +++ b/docs/web3.main.rst @@ -33,7 +33,7 @@ Attributes Returns the current Web3 version. .. code-block:: python - + >>> web3.api "4.7.0" diff --git a/docs/web3.pm.rst b/docs/web3.pm.rst index 289859ce9d..4c0f32f107 100644 --- a/docs/web3.pm.rst +++ b/docs/web3.pm.rst @@ -48,7 +48,7 @@ Creating your own Registry class If you want to implement your own registry and use it with ``web3.pm``, you must create a subclass that inherits from ``ERC1319Registry``, and implements all the `ERC 1319 standard methods `_ prefixed with an underscore in ``ERC1319Registry``. Then, you have to manually set it as the ``registry`` attribute on ``web3.pm``. .. code-block:: python - + custom_registry = CustomRegistryClass(address, w3) w3.pm.registry = custom_registry diff --git a/ens/main.py b/ens/main.py index f1cc28ff45..51b9f04602 100644 --- a/ens/main.py +++ b/ens/main.py @@ -84,18 +84,18 @@ def __init__( :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. """ - self.web3 = init_web3(provider) + self.w3 = init_web3(provider) ens_addr = addr if addr else ENS_MAINNET_ADDR self.ens = self.web3.eth.contract(abi=abis.ENS, address=ens_addr) self._resolverContract = self.web3.eth.contract(abi=abis.RESOLVER) @classmethod - def fromWeb3(cls, web3: 'Web3', addr: ChecksumAddress = None) -> 'ENS': + def fromWeb3(cls, w3: 'Web3', addr: ChecksumAddress = None) -> 'ENS': """ Generate an ENS instance with web3 - :param `web3.Web3` web3: to infer connection information + :param `web3.Web3` w3: to infer connection information :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. """ diff --git a/ethpm/_utils/chains.py b/ethpm/_utils/chains.py index cbdaee7a61..54166c77a0 100644 --- a/ethpm/_utils/chains.py +++ b/ethpm/_utils/chains.py @@ -30,7 +30,7 @@ from web3 import Web3 # noqa: F401 -def get_genesis_block_hash(web3: "Web3") -> HexBytes: +def get_genesis_block_hash(w3: "Web3") -> HexBytes: return web3.eth.get_block(BlockNumber(0))["hash"] diff --git a/ethpm/contract.py b/ethpm/contract.py index 92dfa2faaf..5df60956c3 100644 --- a/ethpm/contract.py +++ b/ethpm/contract.py @@ -60,7 +60,7 @@ def __init__(self, address: bytes, **kwargs: Any) -> None: @classmethod def factory( - cls, web3: "Web3", class_name: str = None, **kwargs: Any + cls, w3: "Web3", class_name: str = None, **kwargs: Any ) -> Contract: dep_link_refs = kwargs.get("unlinked_references") bytecode = kwargs.get("bytecode") diff --git a/ethpm/uri.py b/ethpm/uri.py index 35c8288399..b77ec216c4 100644 --- a/ethpm/uri.py +++ b/ethpm/uri.py @@ -120,7 +120,7 @@ def create_latest_block_uri(w3: "Web3", from_blocks_ago: int = 3) -> URI: @curry -def check_if_chain_matches_chain_uri(web3: "Web3", blockchain_uri: URI) -> bool: +def check_if_chain_matches_chain_uri(w3: "Web3", blockchain_uri: URI) -> bool: chain_id, resource_type, resource_hash = parse_BIP122_uri(blockchain_uri) genesis_block = web3.eth.get_block("earliest") diff --git a/tests/core/contracts/conftest.py b/tests/core/contracts/conftest.py index a3b97b745a..17f7fefbd0 100644 --- a/tests/core/contracts/conftest.py +++ b/tests/core/contracts/conftest.py @@ -478,7 +478,7 @@ def EVENT_CONTRACT( @pytest.fixture() def EventContract(web3_empty, EVENT_CONTRACT): - web3 = web3_empty + w3 = web3_empty return web3.eth.contract(**EVENT_CONTRACT) @@ -490,7 +490,7 @@ def event_contract( wait_for_block, address_conversion_func): - web3 = web3_empty + w3 = web3_empty wait_for_block(web3) deploy_txn_hash = EventContract.constructor().transact({ @@ -535,7 +535,7 @@ def INDEXED_EVENT_CONTRACT( @pytest.fixture() def IndexedEventContract(web3_empty, INDEXED_EVENT_CONTRACT): - web3 = web3_empty + w3 = web3_empty return web3.eth.contract(**INDEXED_EVENT_CONTRACT) @@ -547,7 +547,7 @@ def indexed_event( wait_for_block, address_conversion_func): - web3 = web3_empty + w3 = web3_empty wait_for_block(web3) deploy_txn_hash = IndexedEventContract.constructor().transact({ diff --git a/tests/core/contracts/test_concise_contract.py b/tests/core/contracts/test_concise_contract.py index 82cb5a3693..c1d6b42963 100644 --- a/tests/core/contracts/test_concise_contract.py +++ b/tests/core/contracts/test_concise_contract.py @@ -94,7 +94,7 @@ def test_class_construction_sets_class_vars(web3, ) classic = MathContract(some_address) - assert classic.web3 == web3 + assert classic.w3 == web3 assert classic.bytecode == decode_hex(MATH_CODE) assert classic.bytecode_runtime == decode_hex(MATH_RUNTIME) diff --git a/tests/core/contracts/test_contract_class_construction.py b/tests/core/contracts/test_contract_class_construction.py index 1f5557081d..3d553dd54d 100644 --- a/tests/core/contracts/test_contract_class_construction.py +++ b/tests/core/contracts/test_contract_class_construction.py @@ -23,7 +23,7 @@ def test_class_construction_sets_class_vars(web3, bytecode_runtime=MATH_RUNTIME, ) - assert MathContract.web3 == web3 + assert MathContract.w3 == web3 assert MathContract.bytecode == decode_hex(MATH_CODE) assert MathContract.bytecode_runtime == decode_hex(MATH_RUNTIME) diff --git a/tests/core/contracts/test_contract_init.py b/tests/core/contracts/test_contract_init.py index cdf202205f..97f8b02b93 100644 --- a/tests/core/contracts/test_contract_init.py +++ b/tests/core/contracts/test_contract_init.py @@ -12,7 +12,7 @@ @pytest.fixture() def math_addr(MathContract, address_conversion_func): - web3 = MathContract.web3 + w3 = MathContract.web3 deploy_txn = MathContract.constructor().transact({'from': web3.eth.coinbase}) deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None diff --git a/tests/core/eth-module/test_transactions.py b/tests/core/eth-module/test_transactions.py index cbdc7b927d..827b5925d0 100644 --- a/tests/core/eth-module/test_transactions.py +++ b/tests/core/eth-module/test_transactions.py @@ -20,11 +20,11 @@ 'make_chain_id, expect_success', ( ( - lambda web3: web3.eth.chain_id, + lambda w3: web3.eth.chain_id, True, ), pytest.param( - lambda web3: 999999999999, + lambda w3: 999999999999, False, ), ), diff --git a/tests/core/filtering/test_filter_against_pending_transactions.py b/tests/core/filtering/test_filter_against_pending_transactions.py index e3162a9b8c..0e0e792d62 100644 --- a/tests/core/filtering/test_filter_against_pending_transactions.py +++ b/tests/core/filtering/test_filter_against_pending_transactions.py @@ -16,7 +16,7 @@ def test_sync_filter_against_pending_transactions(web3_empty, wait_for_transaction, skip_if_testrpc ): - web3 = web3_empty + w3 = web3_empty skip_if_testrpc(web3) txn_filter = web3.eth.filter("pending") @@ -51,7 +51,7 @@ def test_async_filter_against_pending_transactions(web3_empty, wait_for_transaction, skip_if_testrpc ): - web3 = web3_empty + w3 = web3_empty skip_if_testrpc(web3) seen_txns = [] diff --git a/tests/core/filtering/test_filter_against_transaction_logs.py b/tests/core/filtering/test_filter_against_transaction_logs.py index b0c13a03ca..c7f0c7d813 100644 --- a/tests/core/filtering/test_filter_against_transaction_logs.py +++ b/tests/core/filtering/test_filter_against_transaction_logs.py @@ -18,7 +18,7 @@ def test_sync_filter_against_log_events(web3_empty, emitter_log_topics, emitter_event_ids ): - web3 = web3_empty + w3 = web3_empty txn_filter = web3.eth.filter({}) @@ -45,7 +45,7 @@ def test_async_filter_against_log_events(web3_empty, emitter_log_topics, emitter_event_ids ): - web3 = web3_empty + w3 = web3_empty seen_logs = [] txn_filter = web3.eth.filter({}) diff --git a/tests/core/middleware/test_gas_price_strategy.py b/tests/core/middleware/test_gas_price_strategy.py index 14bb9bd8c4..c9661fa9ea 100644 --- a/tests/core/middleware/test_gas_price_strategy.py +++ b/tests/core/middleware/test_gas_price_strategy.py @@ -10,9 +10,9 @@ @pytest.fixture def the_gas_price_strategy_middleware(web3): - make_request, web3 = Mock(), Mock() + make_request, w3 = Mock(), Mock() initialized = gas_price_strategy_middleware(make_request, web3) - initialized.web3 = web3 + initialized.w3 = web3 initialized.make_request = make_request return initialized diff --git a/tests/core/middleware/test_http_request_retry.py b/tests/core/middleware/test_http_request_retry.py index 7558a9df1c..f8cd919cd6 100644 --- a/tests/core/middleware/test_http_request_retry.py +++ b/tests/core/middleware/test_http_request_retry.py @@ -24,11 +24,11 @@ @pytest.fixture def exception_retry_request_setup(): - web3 = Mock() + w3 = Mock() provider = HTTPProvider() errors = (ConnectionError, HTTPError, Timeout, TooManyRedirects) setup = exception_retry_middleware(provider.make_request, web3, errors, 5) - setup.web3 = web3 + setup.w3 = web3 return setup @@ -68,10 +68,10 @@ def test_valid_method_retried(make_post_request_mock, exception_retry_request_se def test_is_strictly_default_http_middleware(): - web3 = HTTPProvider() + w3 = HTTPProvider() assert 'http_retry_request' in web3.middlewares - web3 = IPCProvider() + w3 = IPCProvider() assert 'http_retry_request' not in web3.middlewares diff --git a/tests/core/middleware/test_stalecheck.py b/tests/core/middleware/test_stalecheck.py index f406fa50bf..1d9def8403 100644 --- a/tests/core/middleware/test_stalecheck.py +++ b/tests/core/middleware/test_stalecheck.py @@ -30,10 +30,10 @@ def allowable_delay(): @pytest.fixture def request_middleware(allowable_delay): middleware = make_stalecheck_middleware(allowable_delay) - make_request, web3 = Mock(), Mock() + make_request, w3 = Mock(), Mock() initialized = middleware(make_request, web3) # for easier mocking, later: - initialized.web3 = web3 + initialized.w3 = web3 initialized.make_request = make_request return initialized diff --git a/tests/core/mining-module/test_miner_hashrate.py b/tests/core/mining-module/test_miner_hashrate.py index d28acfcc72..efb592da73 100644 --- a/tests/core/mining-module/test_miner_hashrate.py +++ b/tests/core/mining-module/test_miner_hashrate.py @@ -5,7 +5,7 @@ @flaky(max_runs=3) def test_miner_hashrate(web3_empty, wait_for_miner_start): - web3 = web3_empty + w3 = web3_empty hashrate = web3.eth.hashrate assert hashrate > 0 diff --git a/tests/core/mining-module/test_miner_setExtra.py b/tests/core/mining-module/test_miner_setExtra.py index ecbf4786bf..ba9824ee5b 100644 --- a/tests/core/mining-module/test_miner_setExtra.py +++ b/tests/core/mining-module/test_miner_setExtra.py @@ -15,7 +15,7 @@ @flaky(max_runs=3) def test_miner_set_extra(web3_empty, wait_for_block): - web3 = web3_empty + w3 = web3_empty initial_extra = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) @@ -40,7 +40,7 @@ def test_miner_set_extra(web3_empty, wait_for_block): @flaky(max_runs=3) def test_miner_setExtra(web3_empty, wait_for_block): - web3 = web3_empty + w3 = web3_empty initial_extra = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) diff --git a/tests/core/mining-module/test_miner_setGasPrice.py b/tests/core/mining-module/test_miner_setGasPrice.py index 70852cf20a..f3065fbbe0 100644 --- a/tests/core/mining-module/test_miner_setGasPrice.py +++ b/tests/core/mining-module/test_miner_setGasPrice.py @@ -12,7 +12,7 @@ @flaky(max_runs=3) def test_miner_set_gas_price(web3_empty, wait_for_block): - web3 = web3_empty + w3 = web3_empty initial_gas_price = web3.eth.gas_price @@ -31,7 +31,7 @@ def test_miner_set_gas_price(web3_empty, wait_for_block): @flaky(max_runs=3) def test_miner_setGasPrice(web3_empty, wait_for_block): - web3 = web3_empty + w3 = web3_empty initial_gas_price = web3.eth.gas_price assert web3.eth.gas_price > 1000 diff --git a/tests/core/mining-module/test_miner_start.py b/tests/core/mining-module/test_miner_start.py index 80de7839c4..a6e9fe0040 100644 --- a/tests/core/mining-module/test_miner_start.py +++ b/tests/core/mining-module/test_miner_start.py @@ -11,7 +11,7 @@ @flaky(max_runs=3) def test_miner_start(web3_empty, wait_for_miner_start): - web3 = web3_empty + w3 = web3_empty # sanity assert web3.eth.mining diff --git a/tests/core/mining-module/test_miner_stop.py b/tests/core/mining-module/test_miner_stop.py index 60b6633b3f..5b962cf5d1 100644 --- a/tests/core/mining-module/test_miner_stop.py +++ b/tests/core/mining-module/test_miner_stop.py @@ -11,7 +11,7 @@ @flaky(max_runs=3) def test_miner_stop(web3_empty): - web3 = web3_empty + w3 = web3_empty assert web3.eth.mining assert web3.eth.hashrate diff --git a/tests/core/mining-module/test_setEtherBase.py b/tests/core/mining-module/test_setEtherBase.py index a057e851e4..a1bab63e9e 100644 --- a/tests/core/mining-module/test_setEtherBase.py +++ b/tests/core/mining-module/test_setEtherBase.py @@ -2,7 +2,7 @@ def test_miner_set_etherbase(web3_empty): - web3 = web3_empty + w3 = web3_empty assert web3.eth.coinbase == web3.eth.accounts[0] new_account = web3.personal.newAccount('this-is-a-password') web3.geth.miner.set_etherbase(new_account) @@ -10,7 +10,7 @@ def test_miner_set_etherbase(web3_empty): def test_miner_setEtherbase(web3_empty): - web3 = web3_empty + w3 = web3_empty assert web3.eth.coinbase == web3.eth.accounts[0] new_account = web3.personal.newAccount('this-is-a-password') with pytest.warns(DeprecationWarning): diff --git a/tests/core/providers/test_http_provider.py b/tests/core/providers/test_http_provider.py index f0e28c43aa..24c94b584d 100644 --- a/tests/core/providers/test_http_provider.py +++ b/tests/core/providers/test_http_provider.py @@ -18,14 +18,14 @@ def test_no_args(): provider = HTTPProvider() - web3 = Web3(provider) + w3 = Web3(provider) assert web3.manager.provider == provider def test_init_kwargs(): provider = HTTPProvider(endpoint_uri=URI, request_kwargs={'timeout': 60}) - web3 = Web3(provider) + w3 = Web3(provider) assert web3.manager.provider == provider @@ -36,7 +36,7 @@ def test_user_provided_session(): session.mount('https://', adapter) provider = HTTPProvider(endpoint_uri=URI, session=session) - web3 = Web3(provider) + w3 = Web3(provider) assert web3.manager.provider == provider session = request._get_session(URI) diff --git a/tests/core/providers/test_provider.py b/tests/core/providers/test_provider.py index d71744fb3a..87c605308e 100644 --- a/tests/core/providers/test_provider.py +++ b/tests/core/providers/test_provider.py @@ -19,7 +19,7 @@ def test_isConnected_connected(): """ Web3.isConnected() returns True when connected to a node. """ - web3 = Web3(ConnectedProvider()) + w3 = Web3(ConnectedProvider()) assert web3.isConnected() is True @@ -28,7 +28,7 @@ def test_isConnected_disconnected(): Web3.isConnected() returns False when configured with a provider that's not connected to a node. """ - web3 = Web3(DisconnectedProvider()) + w3 = Web3(DisconnectedProvider()) assert web3.isConnected() is False diff --git a/tests/core/txpool-module/test_txpool_content.py b/tests/core/txpool-module/test_txpool_content.py index 10a7a364e3..3375626d23 100644 --- a/tests/core/txpool-module/test_txpool_content.py +++ b/tests/core/txpool-module/test_txpool_content.py @@ -6,7 +6,7 @@ def test_txpool_content(web3_empty): - web3 = web3_empty + w3 = web3_empty web3.geth.miner.stop() diff --git a/tests/core/txpool-module/test_txpool_inspect.py b/tests/core/txpool-module/test_txpool_inspect.py index 2e2c5239f3..defd6ec80b 100644 --- a/tests/core/txpool-module/test_txpool_inspect.py +++ b/tests/core/txpool-module/test_txpool_inspect.py @@ -6,7 +6,7 @@ def test_txpool_inspect(web3_empty): - web3 = web3_empty + w3 = web3_empty web3.geth.miner.stop() diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index 41ff0682e0..f6e152f6a9 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -136,7 +136,7 @@ def generate_go_ethereum_fixture(destination_dir): geth_port=geth_port): common.wait_for_socket(geth_ipc_path) - web3 = Web3(Web3.IPCProvider(geth_ipc_path)) + w3 = Web3(Web3.IPCProvider(geth_ipc_path)) chain_data = setup_chain_state(web3) # close geth by exiting context # must be closed before copying data dir @@ -152,7 +152,7 @@ def generate_go_ethereum_fixture(destination_dir): geth_port=geth_port): common.wait_for_socket(geth_ipc_path) - web3 = Web3(Web3.IPCProvider(geth_ipc_path)) + w3 = Web3(Web3.IPCProvider(geth_ipc_path)) verify_chain_state(web3, chain_data) static_data = { diff --git a/tests/integration/generate_fixtures/parity.py b/tests/integration/generate_fixtures/parity.py index d6eb24688a..ca74ccae7d 100644 --- a/tests/integration/generate_fixtures/parity.py +++ b/tests/integration/generate_fixtures/parity.py @@ -288,7 +288,7 @@ def generate_parity_fixture(destination_dir): )) common.wait_for_socket(parity_ipc_path) - web3 = Web3(Web3.IPCProvider(parity_ipc_path)) + w3 = Web3(Web3.IPCProvider(parity_ipc_path)) time.sleep(10) connect_nodes(web3, web3_geth) diff --git a/tests/integration/go_ethereum/test_goethereum_http.py b/tests/integration/go_ethereum/test_goethereum_http.py index fca859ff9a..2aa1b9e6de 100644 --- a/tests/integration/go_ethereum/test_goethereum_http.py +++ b/tests/integration/go_ethereum/test_goethereum_http.py @@ -59,7 +59,7 @@ def geth_command_arguments(rpc_port, @pytest.fixture(scope="module") def web3(geth_process, endpoint_uri): wait_for_http(endpoint_uri) - _web3 = Web3(Web3.HTTPProvider(endpoint_uri)) + _w3 = Web3(Web3.HTTPProvider(endpoint_uri)) return _web3 @@ -69,15 +69,15 @@ class TestGoEthereumTest(GoEthereumTest): class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest): @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - def test_admin_peers(self, web3: "Web3") -> None: + def test_admin_peers(self, w3: "Web3") -> None: super().test_admin_peers(web3) - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time') super().test_admin_start_stop_rpc(web3) - def test_admin_start_stop_ws(self, web3: "Web3") -> None: + def test_admin_start_stop_ws(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time') super().test_admin_start_stop_ws(web3) diff --git a/tests/integration/go_ethereum/test_goethereum_ipc.py b/tests/integration/go_ethereum/test_goethereum_ipc.py index f95db63853..9d9d2a70f2 100644 --- a/tests/integration/go_ethereum/test_goethereum_ipc.py +++ b/tests/integration/go_ethereum/test_goethereum_ipc.py @@ -54,7 +54,7 @@ def geth_ipc_path(datadir): @pytest.fixture(scope="module") def web3(geth_process, geth_ipc_path): wait_for_socket(geth_ipc_path) - _web3 = Web3(Web3.IPCProvider(geth_ipc_path)) + _w3 = Web3(Web3.IPCProvider(geth_ipc_path)) return _web3 diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 449fd64179..5041b81efa 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -65,7 +65,7 @@ def geth_command_arguments(geth_binary, @pytest.fixture(scope="module") def web3(geth_process, endpoint_uri, event_loop): event_loop.run_until_complete(wait_for_ws(endpoint_uri, event_loop)) - _web3 = Web3(Web3.WebsocketProvider(endpoint_uri)) + _w3 = Web3(Web3.WebsocketProvider(endpoint_uri)) return _web3 @@ -75,15 +75,15 @@ class TestGoEthereumTest(GoEthereumTest): class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest): @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - def test_admin_peers(self, web3: "Web3") -> None: + def test_admin_peers(self, w3: "Web3") -> None: super().test_admin_peers(web3) - def test_admin_start_stop_ws(self, web3: "Web3") -> None: + def test_admin_start_stop_ws(self, w3: "Web3") -> None: # This test inconsistently causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one WebSocket endpoint is allowed to be active at any time') super().test_admin_start_stop_ws(web3) - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: pytest.xfail(reason="This test inconsistently causes all tests after it on CI to fail if it's allowed to run") # noqa: E501 super().test_admin_start_stop_ws(web3) diff --git a/tests/integration/parity/test_parity_http.py b/tests/integration/parity/test_parity_http.py index 3c2cc7cd0f..c6bf6b1d96 100644 --- a/tests/integration/parity/test_parity_http.py +++ b/tests/integration/parity/test_parity_http.py @@ -76,7 +76,7 @@ def parity_import_blocks_command(parity_binary, rpc_port, datadir, passwordfile) @pytest.fixture(scope="module") # noqa: F811 def web3(parity_process, endpoint_uri): wait_for_http(endpoint_uri) - _web3 = Web3(Web3.HTTPProvider(endpoint_uri)) + _w3 = Web3(Web3.HTTPProvider(endpoint_uri)) return _web3 diff --git a/tests/integration/parity/test_parity_ipc.py b/tests/integration/parity/test_parity_ipc.py index e0f202fc65..4be012054a 100644 --- a/tests/integration/parity/test_parity_ipc.py +++ b/tests/integration/parity/test_parity_ipc.py @@ -74,7 +74,7 @@ def parity_import_blocks_command(parity_binary, ipc_path, datadir, passwordfile) @pytest.fixture(scope="module") # noqa: F811 def web3(parity_process, ipc_path): wait_for_socket(ipc_path) - _web3 = Web3(Web3.IPCProvider(ipc_path)) + _w3 = Web3(Web3.IPCProvider(ipc_path)) return _web3 diff --git a/tests/integration/parity/test_parity_ws.py b/tests/integration/parity/test_parity_ws.py index 330a5d9fa5..4bc44f00e3 100644 --- a/tests/integration/parity/test_parity_ws.py +++ b/tests/integration/parity/test_parity_ws.py @@ -79,7 +79,7 @@ def parity_import_blocks_command(parity_binary, ws_port, datadir, passwordfile): @pytest.fixture(scope="module") # noqa: F811 def web3(parity_process, endpoint_uri, event_loop): event_loop.run_until_complete(wait_for_ws(endpoint_uri, event_loop)) - _web3 = Web3(Web3.WebsocketProvider(endpoint_uri)) + _w3 = Web3(Web3.WebsocketProvider(endpoint_uri)) return _web3 diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index 2caaf1b398..6ef83c3bde 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -46,7 +46,7 @@ def eth_tester_provider(eth_tester): @pytest.fixture(scope="module") def web3(eth_tester_provider): - _web3 = Web3(eth_tester_provider) + _w3 = Web3(eth_tester_provider) return _web3 @@ -266,7 +266,7 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_submit_work = not_implemented(EthModuleTest.test_eth_submit_work, ValueError) def test_eth_getBlockByHash_pending( - self, web3: "Web3" + self, w3: "Web3" ) -> None: block = web3.eth.get_block('pending') assert block['hash'] is not None @@ -464,5 +464,5 @@ def test_personal_unlockAccount_failure_deprecated(self, assert result is False @pytest.mark.xfail(raises=ValueError, reason="list_wallets not implemented in eth-tester") - def test_personal_list_wallets(self, web3: "Web3") -> None: + def test_personal_list_wallets(self, w3: "Web3") -> None: super().test_personal_list_wallets(web3) diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index c7d6f45829..4e4b8fd2ab 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -164,7 +164,7 @@ def find_matching_fn_abi( def encode_abi( - web3: "Web3", abi: ABIFunction, arguments: Sequence[Any], data: Optional[HexStr] = None + w3: "Web3", abi: ABIFunction, arguments: Sequence[Any], data: Optional[HexStr] = None ) -> HexStr: argument_types = get_abi_input_types(abi) @@ -200,7 +200,7 @@ def encode_abi( def prepare_transaction( address: ChecksumAddress, - web3: "Web3", + w3: "Web3", fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]], contract_abi: Optional[ABI] = None, fn_abi: Optional[ABIFunction] = None, @@ -242,7 +242,7 @@ def prepare_transaction( def encode_transaction_data( - web3: "Web3", + w3: "Web3", fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]], contract_abi: Optional[ABI] = None, fn_abi: Optional[ABIFunction] = None, diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index bb25323542..64f49aab56 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -59,7 +59,7 @@ class EthModuleTest: - def test_eth_protocol_version(self, web3: "Web3") -> None: + def test_eth_protocol_version(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning, match="This method has been deprecated in some clients"): protocol_version = web3.eth.protocol_version @@ -67,14 +67,14 @@ def test_eth_protocol_version(self, web3: "Web3") -> None: assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_protocolVersion(self, web3: "Web3") -> None: + def test_eth_protocolVersion(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): protocol_version = web3.eth.protocolVersion assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_syncing(self, web3: "Web3") -> None: + def test_eth_syncing(self, w3: "Web3") -> None: syncing = web3.eth.syncing assert is_boolean(syncing) or is_dict(syncing) @@ -91,42 +91,42 @@ def test_eth_syncing(self, web3: "Web3") -> None: assert is_integer(sync_dict['currentBlock']) assert is_integer(sync_dict['highestBlock']) - def test_eth_coinbase(self, web3: "Web3") -> None: + def test_eth_coinbase(self, w3: "Web3") -> None: coinbase = web3.eth.coinbase assert is_checksum_address(coinbase) - def test_eth_mining(self, web3: "Web3") -> None: + def test_eth_mining(self, w3: "Web3") -> None: mining = web3.eth.mining assert is_boolean(mining) - def test_eth_hashrate(self, web3: "Web3") -> None: + def test_eth_hashrate(self, w3: "Web3") -> None: hashrate = web3.eth.hashrate assert is_integer(hashrate) assert hashrate >= 0 - def test_eth_chain_id(self, web3: "Web3") -> None: + def test_eth_chain_id(self, w3: "Web3") -> None: chain_id = web3.eth.chain_id # chain id value from geth fixture genesis file assert chain_id == 131277322940537 - def test_eth_chainId(self, web3: "Web3") -> None: + def test_eth_chainId(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): chain_id = web3.eth.chainId # chain id value from geth fixture genesis file assert chain_id == 131277322940537 - def test_eth_gas_price(self, web3: "Web3") -> None: + def test_eth_gas_price(self, w3: "Web3") -> None: gas_price = web3.eth.gas_price assert is_integer(gas_price) assert gas_price > 0 - def test_eth_gasPrice_deprecated(self, web3: "Web3") -> None: + def test_eth_gasPrice_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): gas_price = web3.eth.gasPrice assert is_integer(gas_price) assert gas_price > 0 - def test_eth_accounts(self, web3: "Web3") -> None: + def test_eth_accounts(self, w3: "Web3") -> None: accounts = web3.eth.accounts assert is_list_like(accounts) assert len(accounts) != 0 @@ -137,24 +137,24 @@ def test_eth_accounts(self, web3: "Web3") -> None: )) assert web3.eth.coinbase in accounts - def test_eth_block_number(self, web3: "Web3") -> None: + def test_eth_block_number(self, w3: "Web3") -> None: block_number = web3.eth.block_number assert is_integer(block_number) assert block_number >= 0 - def test_eth_get_block_number(self, web3: "Web3") -> None: + def test_eth_get_block_number(self, w3: "Web3") -> None: block_number = web3.eth.get_block_number() assert is_integer(block_number) assert block_number >= 0 - def test_eth_blockNumber(self, web3: "Web3") -> None: + def test_eth_blockNumber(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): block_number = web3.eth.blockNumber assert is_integer(block_number) assert block_number >= 0 - def test_eth_get_balance(self, web3: "Web3") -> None: + def test_eth_get_balance(self, w3: "Web3") -> None: coinbase = web3.eth.coinbase with pytest.raises(InvalidAddress): @@ -165,7 +165,7 @@ def test_eth_get_balance(self, web3: "Web3") -> None: assert is_integer(balance) assert balance >= 0 - def test_eth_getBalance_deprecated(self, web3: "Web3") -> None: + def test_eth_getBalance_deprecated(self, w3: "Web3") -> None: coinbase = web3.eth.coinbase with pytest.warns(DeprecationWarning, @@ -175,7 +175,7 @@ def test_eth_getBalance_deprecated(self, web3: "Web3") -> None: assert is_integer(balance) assert balance >= 0 - def test_eth_get_balance_with_block_identifier(self, web3: "Web3") -> None: + def test_eth_get_balance_with_block_identifier(self, w3: "Web3") -> None: miner_address = web3.eth.get_block(1)['miner'] genesis_balance = web3.eth.get_balance(miner_address, 0) later_balance = web3.eth.get_balance(miner_address, 1) @@ -189,7 +189,7 @@ def test_eth_get_balance_with_block_identifier(self, web3: "Web3") -> None: ('not-an-address.eth', False) ]) def test_eth_get_balance_with_ens_name( - self, web3: "Web3", address: ChecksumAddress, expect_success: bool + self, w3: "Web3", address: ChecksumAddress, expect_success: bool ) -> None: with ens_addresses(web3, {'test-address.eth': web3.eth.accounts[0]}): if expect_success: @@ -201,39 +201,39 @@ def test_eth_get_balance_with_ens_name( web3.eth.get_balance(address) def test_eth_get_storage_at( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: storage = web3.eth.get_storage_at(emitter_contract_address, 0) assert isinstance(storage, HexBytes) def test_eth_getStorageAt_deprecated( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): storage = web3.eth.getStorageAt(emitter_contract_address, 0) assert isinstance(storage, HexBytes) def test_eth_get_storage_at_ens_name( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: with ens_addresses(web3, {'emitter.eth': emitter_contract_address}): storage = web3.eth.get_storage_at('emitter.eth', 0) assert isinstance(storage, HexBytes) - def test_eth_get_storage_at_invalid_address(self, web3: "Web3") -> None: + def test_eth_get_storage_at_invalid_address(self, w3: "Web3") -> None: coinbase = web3.eth.coinbase with pytest.raises(InvalidAddress): web3.eth.get_storage_at(ChecksumAddress(HexAddress(HexStr(coinbase.lower()))), 0) def test_eth_get_transaction_count( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: transaction_count = web3.eth.get_transaction_count(unlocked_account_dual_type) assert is_integer(transaction_count) assert transaction_count >= 0 def test_eth_getTransactionCount_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): transaction_count = web3.eth.getTransactionCount(unlocked_account_dual_type) @@ -241,20 +241,20 @@ def test_eth_getTransactionCount_deprecated( assert transaction_count >= 0 def test_eth_get_transaction_count_ens_name( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with ens_addresses(web3, {'unlocked-acct-dual-type.eth': unlocked_account_dual_type}): transaction_count = web3.eth.get_transaction_count('unlocked-acct-dual-type.eth') assert is_integer(transaction_count) assert transaction_count >= 0 - def test_eth_get_transaction_count_invalid_address(self, web3: "Web3") -> None: + def test_eth_get_transaction_count_invalid_address(self, w3: "Web3") -> None: coinbase = web3.eth.coinbase with pytest.raises(InvalidAddress): web3.eth.get_transaction_count(ChecksumAddress(HexAddress(HexStr(coinbase.lower())))) def test_eth_getBlockTransactionCountByHash_empty_block( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: transaction_count = web3.eth.get_block_transaction_count(empty_block['hash']) @@ -262,7 +262,7 @@ def test_eth_getBlockTransactionCountByHash_empty_block( assert transaction_count == 0 def test_eth_getBlockTransactionCountByNumber_empty_block( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: transaction_count = web3.eth.get_block_transaction_count(empty_block['number']) @@ -270,7 +270,7 @@ def test_eth_getBlockTransactionCountByNumber_empty_block( assert transaction_count == 0 def test_eth_getBlockTransactionCountByHash_block_with_txn( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: transaction_count = web3.eth.get_block_transaction_count(block_with_txn['hash']) @@ -278,7 +278,7 @@ def test_eth_getBlockTransactionCountByHash_block_with_txn( assert transaction_count >= 1 def test_eth_getBlockTransactionCountByNumber_block_with_txn( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: transaction_count = web3.eth.get_block_transaction_count(block_with_txn['number']) @@ -286,7 +286,7 @@ def test_eth_getBlockTransactionCountByNumber_block_with_txn( assert transaction_count >= 1 def test_eth_getBlockTransactionCountByHash_block_with_txn_deprecated( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.warns( DeprecationWarning, @@ -298,7 +298,7 @@ def test_eth_getBlockTransactionCountByHash_block_with_txn_deprecated( assert transaction_count >= 1 def test_eth_getBlockTransactionCountByNumber_block_with_txn_deprecated( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.warns( DeprecationWarning, @@ -309,14 +309,14 @@ def test_eth_getBlockTransactionCountByNumber_block_with_txn_deprecated( assert is_integer(transaction_count) assert transaction_count >= 1 - def test_eth_getUncleCountByBlockHash(self, web3: "Web3", empty_block: BlockData) -> None: + def test_eth_getUncleCountByBlockHash(self, w3: "Web3", empty_block: BlockData) -> None: uncle_count = web3.eth.get_uncle_count(empty_block['hash']) assert is_integer(uncle_count) assert uncle_count == 0 def test_eth_getUncleCountByBlockHash_deprecated(self, - web3: "Web3", + w3: "Web3", empty_block: BlockData) -> None: with pytest.warns(DeprecationWarning, match='getUncleCount is deprecated in favor of get_uncle_count'): @@ -325,14 +325,14 @@ def test_eth_getUncleCountByBlockHash_deprecated(self, assert is_integer(uncle_count) assert uncle_count == 0 - def test_eth_getUncleCountByBlockNumber(self, web3: "Web3", empty_block: BlockData) -> None: + def test_eth_getUncleCountByBlockNumber(self, w3: "Web3", empty_block: BlockData) -> None: uncle_count = web3.eth.get_uncle_count(empty_block['number']) assert is_integer(uncle_count) assert uncle_count == 0 def test_eth_getUncleCountByBlockNumber_deprecated(self, - web3: "Web3", + w3: "Web3", empty_block: BlockData) -> None: with pytest.warns(DeprecationWarning, match='getUncleCount is deprecated in favor of get_uncle_count'): @@ -341,13 +341,13 @@ def test_eth_getUncleCountByBlockNumber_deprecated(self, assert is_integer(uncle_count) assert uncle_count == 0 - def test_eth_get_code(self, web3: "Web3", math_contract_address: ChecksumAddress) -> None: + def test_eth_get_code(self, w3: "Web3", math_contract_address: ChecksumAddress) -> None: code = web3.eth.get_code(math_contract_address) assert isinstance(code, HexBytes) assert len(code) > 0 def test_eth_getCode_deprecated(self, - web3: "Web3", + w3: "Web3", math_contract_address: ChecksumAddress) -> None: with pytest.warns(DeprecationWarning, match='getCode is deprecated in favor of get_code'): code = web3.eth.getCode(math_contract_address) @@ -355,7 +355,7 @@ def test_eth_getCode_deprecated(self, assert len(code) > 0 def test_eth_get_code_ens_address( - self, web3: "Web3", math_contract_address: ChecksumAddress + self, w3: "Web3", math_contract_address: ChecksumAddress ) -> None: with ens_addresses( web3, {'mathcontract.eth': math_contract_address} @@ -364,18 +364,18 @@ def test_eth_get_code_ens_address( assert isinstance(code, HexBytes) assert len(code) > 0 - def test_eth_get_code_invalid_address(self, web3: "Web3", math_contract: "Contract") -> None: + def test_eth_get_code_invalid_address(self, w3: "Web3", math_contract: "Contract") -> None: with pytest.raises(InvalidAddress): web3.eth.get_code(ChecksumAddress(HexAddress(HexStr(math_contract.address.lower())))) def test_eth_get_code_with_block_identifier( - self, web3: "Web3", emitter_contract: "Contract" + self, w3: "Web3", emitter_contract: "Contract" ) -> None: code = web3.eth.get_code(emitter_contract.address, block_identifier=web3.eth.block_number) assert isinstance(code, HexBytes) assert len(code) > 0 - def test_eth_sign(self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress) -> None: + def test_eth_sign(self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress) -> None: signature = web3.eth.sign( unlocked_account_dual_type, text='Message tö sign. Longer than hash!' ) @@ -408,7 +408,7 @@ def test_eth_sign(self, web3: "Web3", unlocked_account_dual_type: ChecksumAddres assert new_signature != signature def test_eth_sign_ens_names( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with ens_addresses(web3, {'unlocked-acct.eth': unlocked_account_dual_type}): signature = web3.eth.sign( @@ -419,7 +419,7 @@ def test_eth_sign_ens_names( def test_eth_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None], ) -> None: @@ -471,7 +471,7 @@ def test_eth_sign_typed_data( def test_eth_signTypedData_deprecated( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None], ) -> None: @@ -523,7 +523,7 @@ def test_eth_signTypedData_deprecated( def test_invalid_eth_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None] ) -> None: @@ -574,7 +574,7 @@ def test_invalid_eth_sign_typed_data( json.loads(invalid_typed_message) ) - def test_eth_sign_transaction(self, web3: "Web3", unlocked_account: ChecksumAddress) -> None: + def test_eth_sign_transaction(self, w3: "Web3", unlocked_account: ChecksumAddress) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, @@ -593,7 +593,7 @@ def test_eth_sign_transaction(self, web3: "Web3", unlocked_account: ChecksumAddr assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_signTransaction_deprecated(self, - web3: "Web3", + w3: "Web3", unlocked_account: ChecksumAddress) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -615,7 +615,7 @@ def test_eth_signTransaction_deprecated(self, assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_sign_transaction_ens_names( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: with ens_addresses(web3, {'unlocked-account.eth': unlocked_account}): txn_params: TxParams = { @@ -636,7 +636,7 @@ def test_eth_sign_transaction_ens_names( assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_send_transaction_addr_checksum_required( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: non_checksum_addr = unlocked_account.lower() txn_params: TxParams = { @@ -656,7 +656,7 @@ def test_eth_send_transaction_addr_checksum_required( web3.eth.send_transaction(invalid_params) def test_eth_send_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -675,7 +675,7 @@ def test_eth_send_transaction( assert txn['gasPrice'] == txn_params['gasPrice'] def test_eth_sendTransaction_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -696,7 +696,7 @@ def test_eth_sendTransaction_deprecated( assert txn['gasPrice'] == txn_params['gasPrice'] def test_eth_send_transaction_with_nonce( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -718,7 +718,7 @@ def test_eth_send_transaction_with_nonce( assert txn['nonce'] == txn_params['nonce'] def test_eth_replace_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -740,7 +740,7 @@ def test_eth_replace_transaction( assert replace_txn['gasPrice'] == txn_params['gasPrice'] def test_eth_replaceTransaction_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -766,7 +766,7 @@ def test_eth_replaceTransaction_deprecated( assert replace_txn['gasPrice'] == txn_params['gasPrice'] def test_eth_replace_transaction_non_existing_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -782,7 +782,7 @@ def test_eth_replace_transaction_non_existing_transaction( ) def test_eth_replace_transaction_already_mined( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -799,7 +799,7 @@ def test_eth_replace_transaction_already_mined( web3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_incorrect_nonce( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -817,7 +817,7 @@ def test_eth_replace_transaction_incorrect_nonce( web3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_gas_price_too_low( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -833,7 +833,7 @@ def test_eth_replace_transaction_gas_price_too_low( web3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_gas_price_defaulting_minimum( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -851,7 +851,7 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum( assert replace_txn['gasPrice'] == 12 # minimum gas price def test_eth_replace_transaction_gas_price_defaulting_strategy_higher( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -862,7 +862,7 @@ def test_eth_replace_transaction_gas_price_defaulting_strategy_higher( } txn_hash = web3.eth.send_transaction(txn_params) - def higher_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: + def higher_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: return Wei(20) web3.eth.set_gas_price_strategy(higher_gas_price_strategy) @@ -873,7 +873,7 @@ def higher_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: assert replace_txn['gasPrice'] == 20 # Strategy provides higher gas price def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -884,7 +884,7 @@ def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( } txn_hash = web3.eth.send_transaction(txn_params) - def lower_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: + def lower_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: return Wei(5) web3.eth.set_gas_price_strategy(lower_gas_price_strategy) @@ -896,7 +896,7 @@ def lower_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: assert replace_txn['gasPrice'] == 12 def test_eth_modify_transaction( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -919,7 +919,7 @@ def test_eth_modify_transaction( assert modified_txn['gasPrice'] == cast(int, txn_params['gasPrice']) * 2 def test_eth_modifyTransaction_deprecated( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, @@ -957,7 +957,7 @@ def test_eth_modifyTransaction_deprecated( ) def test_eth_send_raw_transaction( self, - web3: "Web3", + w3: "Web3", raw_transaction: Union[HexStr, bytes], funded_account_for_raw_txn: ChecksumAddress, expected_hash: HexStr, @@ -966,7 +966,7 @@ def test_eth_send_raw_transaction( assert txn_hash == web3.toBytes(hexstr=expected_hash) def test_eth_call( - self, web3: "Web3", math_contract: "Contract" + self, w3: "Web3", math_contract: "Contract" ) -> None: coinbase = web3.eth.coinbase txn_params = math_contract._prepare_transaction( @@ -980,7 +980,7 @@ def test_eth_call( assert result == 18 def test_eth_call_with_override( - self, web3: "Web3", revert_contract: "Contract" + self, w3: "Web3", revert_contract: "Contract" ) -> None: coinbase = web3.eth.coinbase txn_params = revert_contract._prepare_transaction( @@ -1002,7 +1002,7 @@ def test_eth_call_with_override( assert result is False def test_eth_call_with_0_result( - self, web3: "Web3", math_contract: "Contract" + self, w3: "Web3", math_contract: "Contract" ) -> None: coinbase = web3.eth.coinbase txn_params = math_contract._prepare_transaction( @@ -1017,7 +1017,7 @@ def test_eth_call_with_0_result( def test_eth_call_revert_with_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -1034,7 +1034,7 @@ def test_eth_call_revert_with_msg( def test_eth_call_revert_without_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -1050,7 +1050,7 @@ def test_eth_call_revert_without_msg( def test_eth_estimate_gas_revert_with_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -1067,7 +1067,7 @@ def test_eth_estimate_gas_revert_with_msg( def test_eth_estimate_gas_revert_without_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -1082,7 +1082,7 @@ def test_eth_estimate_gas_revert_without_msg( web3.eth.estimate_gas(txn_params) def test_eth_estimate_gas( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: gas_estimate = web3.eth.estimate_gas({ 'from': unlocked_account_dual_type, @@ -1093,7 +1093,7 @@ def test_eth_estimate_gas( assert gas_estimate > 0 def test_eth_estimateGas_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning, match="estimateGas is deprecated in favor of estimate_gas"): @@ -1106,7 +1106,7 @@ def test_eth_estimateGas_deprecated( assert gas_estimate > 0 def test_eth_estimate_gas_with_block( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: gas_estimate = web3.eth.estimate_gas({ 'from': unlocked_account_dual_type, @@ -1117,65 +1117,65 @@ def test_eth_estimate_gas_with_block( assert gas_estimate > 0 def test_eth_getBlock_deprecated( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.warns(DeprecationWarning, match="getBlock is deprecated in favor of get_block"): block = web3.eth.getBlock(empty_block['hash']) assert block['hash'] == empty_block['hash'] def test_eth_getBlockByHash( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: block = web3.eth.get_block(empty_block['hash']) assert block['hash'] == empty_block['hash'] def test_eth_getBlockByHash_not_found( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.raises(BlockNotFound): web3.eth.get_block(UNKNOWN_HASH) def test_eth_getBlockByHash_pending( - self, web3: "Web3" + self, w3: "Web3" ) -> None: block = web3.eth.get_block('pending') assert block['hash'] is None def test_eth_getBlockByNumber_with_integer( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: block = web3.eth.get_block(empty_block['number']) assert block['number'] == empty_block['number'] def test_eth_getBlockByNumber_with_integer_deprecated( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.warns(DeprecationWarning, match="getBlock is deprecated in favor of get_block"): block = web3.eth.getBlock(empty_block['number']) assert block['number'] == empty_block['number'] def test_eth_getBlockByNumber_latest( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: current_block_number = web3.eth.block_number block = web3.eth.get_block('latest') assert block['number'] == current_block_number def test_eth_getBlockByNumber_not_found( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.raises(BlockNotFound): web3.eth.get_block(BlockNumber(12345)) def test_eth_getBlockByNumber_pending( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: current_block_number = web3.eth.block_number block = web3.eth.get_block('pending') assert block['number'] == current_block_number + 1 def test_eth_getBlockByNumber_earliest( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: genesis_block = web3.eth.get_block(BlockNumber(0)) block = web3.eth.get_block('earliest') @@ -1183,21 +1183,21 @@ def test_eth_getBlockByNumber_earliest( assert block['hash'] == genesis_block['hash'] def test_eth_getBlockByNumber_full_transactions( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: block = web3.eth.get_block(block_with_txn['number'], True) transaction = block['transactions'][0] assert transaction['hash'] == block_with_txn['transactions'][0] # type: ignore def test_eth_getTransactionByHash( - self, web3: "Web3", mined_txn_hash: HexStr + self, w3: "Web3", mined_txn_hash: HexStr ) -> None: transaction = web3.eth.get_transaction(mined_txn_hash) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByHash_deprecated( - self, web3: "Web3", mined_txn_hash: HexStr + self, w3: "Web3", mined_txn_hash: HexStr ) -> None: with pytest.warns(DeprecationWarning, match='getTransaction is deprecated in favor of get_transaction'): @@ -1206,21 +1206,21 @@ def test_eth_getTransactionByHash_deprecated( assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByHash_contract_creation( - self, web3: "Web3", math_contract_deploy_txn_hash: HexStr + self, w3: "Web3", math_contract_deploy_txn_hash: HexStr ) -> None: transaction = web3.eth.get_transaction(math_contract_deploy_txn_hash) assert is_dict(transaction) assert transaction['to'] is None, "to field is %r" % transaction['to'] def test_eth_getTransactionByBlockHashAndIndex( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: transaction = web3.eth.get_transaction_by_block(block_with_txn['hash'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockHashAndIndex_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, @@ -1231,14 +1231,14 @@ def test_eth_getTransactionByBlockHashAndIndex_deprecated( assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockNumberAndIndex( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: transaction = web3.eth.get_transaction_by_block(block_with_txn['number'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockNumberAndIndex_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, @@ -1249,7 +1249,7 @@ def test_eth_getTransactionByBlockNumberAndIndex_deprecated( assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_get_transaction_receipt_mined( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: receipt = web3.eth.get_transaction_receipt(mined_txn_hash) assert is_dict(receipt) @@ -1262,7 +1262,7 @@ def test_eth_get_transaction_receipt_mined( assert is_checksum_address(receipt['from']) def test_eth_getTransactionReceipt_mined_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, @@ -1278,7 +1278,7 @@ def test_eth_getTransactionReceipt_mined_deprecated( assert is_checksum_address(receipt['from']) def test_eth_get_transaction_receipt_unmined( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_hash = web3.eth.send_transaction({ 'from': unlocked_account_dual_type, @@ -1292,7 +1292,7 @@ def test_eth_get_transaction_receipt_unmined( def test_eth_get_transaction_receipt_with_log_entry( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract: "Contract", txn_hash_with_log: HexStr, @@ -1314,15 +1314,15 @@ def test_eth_get_transaction_receipt_with_log_entry( assert log_entry['transactionIndex'] == 0 assert log_entry['transactionHash'] == HexBytes(txn_hash_with_log) - def test_eth_getUncleByBlockHashAndIndex(self, web3: "Web3") -> None: + def test_eth_getUncleByBlockHashAndIndex(self, w3: "Web3") -> None: # TODO: how do we make uncles.... pass - def test_eth_getUncleByBlockNumberAndIndex(self, web3: "Web3") -> None: + def test_eth_getUncleByBlockNumberAndIndex(self, w3: "Web3") -> None: # TODO: how do we make uncles.... pass - def test_eth_newFilter(self, web3: "Web3") -> None: + def test_eth_newFilter(self, w3: "Web3") -> None: filter = web3.eth.filter({}) changes = web3.eth.get_filter_changes(filter.filter_id) @@ -1336,7 +1336,7 @@ def test_eth_newFilter(self, web3: "Web3") -> None: result = web3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newFilter_deprecated(self, web3: "Web3") -> None: + def test_eth_newFilter_deprecated(self, w3: "Web3") -> None: filter = web3.eth.filter({}) changes = web3.eth.get_filter_changes(filter.filter_id) @@ -1352,7 +1352,7 @@ def test_eth_newFilter_deprecated(self, web3: "Web3") -> None: result = web3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newBlockFilter(self, web3: "Web3") -> None: + def test_eth_newBlockFilter(self, w3: "Web3") -> None: filter = web3.eth.filter('latest') assert is_string(filter.filter_id) @@ -1368,7 +1368,7 @@ def test_eth_newBlockFilter(self, web3: "Web3") -> None: result = web3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newPendingTransactionFilter(self, web3: "Web3") -> None: + def test_eth_newPendingTransactionFilter(self, w3: "Web3") -> None: filter = web3.eth.filter('pending') assert is_string(filter.filter_id) @@ -1385,7 +1385,7 @@ def test_eth_newPendingTransactionFilter(self, web3: "Web3") -> None: assert result is True def test_eth_get_logs_without_logs( - self, web3: "Web3", block_with_txn_with_log: BlockData + self, w3: "Web3", block_with_txn_with_log: BlockData ) -> None: # Test with block range @@ -1426,7 +1426,7 @@ def test_eth_get_logs_without_logs( def test_eth_get_logs_with_logs( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract_address: ChecksumAddress, txn_hash_with_log: HexStr, @@ -1468,7 +1468,7 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: def test_eth_get_logs_with_logs_topic_args( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract_address: ChecksumAddress, txn_hash_with_log: HexStr, @@ -1505,7 +1505,7 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: result = web3.eth.get_logs(filter_params) assert_contains_log(result) - def test_eth_get_logs_with_logs_none_topic_args(self, web3: "Web3") -> None: + def test_eth_get_logs_with_logs_none_topic_args(self, w3: "Web3") -> None: # Test with None overflowing filter_params: FilterParams = { "fromBlock": BlockNumber(0), @@ -1516,7 +1516,7 @@ def test_eth_get_logs_with_logs_none_topic_args(self, web3: "Web3") -> None: assert len(result) == 0 def test_eth_call_old_contract_state( - self, web3: "Web3", math_contract: "Contract", unlocked_account: ChecksumAddress + self, w3: "Web3", math_contract: "Contract", unlocked_account: ChecksumAddress ) -> None: start_block = web3.eth.get_block('latest') block_num = start_block["number"] @@ -1544,7 +1544,7 @@ def test_eth_call_old_contract_state( if pending_call_result != 1: raise AssertionError("pending call result was %d instead of 1" % pending_call_result) - def test_eth_uninstallFilter_deprecated(self, web3: "Web3") -> None: + def test_eth_uninstallFilter_deprecated(self, w3: "Web3") -> None: filter = web3.eth.filter({}) assert is_string(filter.filter_id) @@ -1558,7 +1558,7 @@ def test_eth_uninstallFilter_deprecated(self, web3: "Web3") -> None: failure = web3.eth.uninstallFilter(filter.filter_id) assert failure is False - def test_eth_uninstall_filter(self, web3: "Web3") -> None: + def test_eth_uninstall_filter(self, w3: "Web3") -> None: filter = web3.eth.filter({}) assert is_string(filter.filter_id) @@ -1569,22 +1569,22 @@ def test_eth_uninstall_filter(self, web3: "Web3") -> None: assert failure is False def test_eth_getTransactionFromBlock_deprecation( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.raises(DeprecationWarning): web3.eth.getTransactionFromBlock(block_with_txn['hash'], 0) - def test_eth_getCompilers_deprecation(self, web3: "Web3") -> None: + def test_eth_getCompilers_deprecation(self, w3: "Web3") -> None: with pytest.raises(DeprecationWarning): web3.eth.getCompilers() - def test_eth_submit_hashrate(self, web3: "Web3") -> None: + def test_eth_submit_hashrate(self, w3: "Web3") -> None: # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c') result = web3.eth.submit_hashrate(5000, node_id) assert result is True - def test_eth_submitHashrate_deprecated(self, web3: "Web3") -> None: + def test_eth_submitHashrate_deprecated(self, w3: "Web3") -> None: # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c') with pytest.warns(DeprecationWarning, @@ -1592,14 +1592,14 @@ def test_eth_submitHashrate_deprecated(self, web3: "Web3") -> None: result = web3.eth.submitHashrate(5000, node_id) assert result is True - def test_eth_submit_work(self, web3: "Web3") -> None: + def test_eth_submit_work(self, w3: "Web3") -> None: nonce = 1 pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') result = web3.eth.submit_work(nonce, pow_hash, mix_digest) assert result is False - def test_eth_submitWork_deprecated(self, web3: "Web3") -> None: + def test_eth_submitWork_deprecated(self, w3: "Web3") -> None: nonce = 1 pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') diff --git a/web3/_utils/module_testing/go_ethereum_admin_module.py b/web3/_utils/module_testing/go_ethereum_admin_module.py index bdfaba9600..b98a354b02 100644 --- a/web3/_utils/module_testing/go_ethereum_admin_module.py +++ b/web3/_utils/module_testing/go_ethereum_admin_module.py @@ -15,16 +15,16 @@ class GoEthereumAdminModuleTest: - def test_add_peer(self, web3: "Web3") -> None: + def test_add_peer(self, w3: "Web3") -> None: result = web3.geth.admin.add_peer( EnodeURI('enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30303'),) # noqa: E501 assert result is True - def test_admin_datadir(self, web3: "Web3", datadir: str) -> None: + def test_admin_datadir(self, w3: "Web3", datadir: str) -> None: result = web3.geth.admin.datadir() assert result == datadir - def test_admin_node_info(self, web3: "Web3") -> None: + def test_admin_node_info(self, w3: "Web3") -> None: result = web3.geth.admin.node_info() expected = AttributeDict({ 'id': '', @@ -38,13 +38,13 @@ def test_admin_node_info(self, web3: "Web3") -> None: # Test that result gives at least the keys that are listed in `expected` assert not set(expected.keys()).difference(result.keys()) - def test_admin_peers(self, web3: "Web3") -> None: + def test_admin_peers(self, w3: "Web3") -> None: enode = web3.geth.admin.node_info()['enode'] web3.geth.admin.add_peer(enode) result = web3.geth.admin.peers() assert len(result) == 1 - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: stop = web3.geth.admin.stop_rpc() assert stop is True @@ -59,7 +59,7 @@ def test_admin_start_stop_rpc(self, web3: "Web3") -> None: start = web3.geth.admin.startRPC() assert start is True - def test_admin_start_stop_ws(self, web3: "Web3") -> None: + def test_admin_start_stop_ws(self, w3: "Web3") -> None: stop = web3.geth.admin.stop_ws() assert stop is True @@ -77,14 +77,14 @@ def test_admin_start_stop_ws(self, web3: "Web3") -> None: # # Deprecated # - def test_admin_addPeer(self, web3: "Web3") -> None: + def test_admin_addPeer(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): result = web3.geth.admin.addPeer( 'enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30303', # noqa: E501 ) assert result is True - def test_admin_nodeInfo(self, web3: "Web3") -> None: + def test_admin_nodeInfo(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): result = web3.geth.admin.nodeInfo() expected = AttributeDict({ diff --git a/web3/_utils/module_testing/net_module.py b/web3/_utils/module_testing/net_module.py index 2330489175..f8fa2f5999 100644 --- a/web3/_utils/module_testing/net_module.py +++ b/web3/_utils/module_testing/net_module.py @@ -14,28 +14,28 @@ class NetModuleTest: - def test_net_version(self, web3: "Web3") -> None: + def test_net_version(self, w3: "Web3") -> None: version = web3.net.version assert is_string(version) assert version.isdigit() - def test_net_listening(self, web3: "Web3") -> None: + def test_net_listening(self, w3: "Web3") -> None: listening = web3.net.listening assert is_boolean(listening) - def test_net_peer_count(self, web3: "Web3") -> None: + def test_net_peer_count(self, w3: "Web3") -> None: peer_count = web3.net.peer_count assert is_integer(peer_count) - def test_net_peerCount(self, web3: "Web3") -> None: + def test_net_peerCount(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): peer_count = web3.net.peerCount assert is_integer(peer_count) - def test_net_chainId_deprecation(self, web3: "Web3") -> None: + def test_net_chainId_deprecation(self, w3: "Web3") -> None: with pytest.raises(DeprecationWarning): web3.net.chainId diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index 3b401c1145..f8a76d1f9b 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -32,7 +32,7 @@ class ParityTraceModuleTest: def test_traceReplayTransaction_deprecated( - self, web3: "Web3", parity_fixture_data: Dict[str, str], + self, w3: "Web3", parity_fixture_data: Dict[str, str], ) -> None: with pytest.warns(DeprecationWarning, match='traceReplayTransaction is deprecated in favor of ' @@ -46,7 +46,7 @@ def test_traceReplayTransaction_deprecated( ) def test_trace_replay_transaction( - self, web3: "Web3", parity_fixture_data: Dict[str, str], + self, w3: "Web3", parity_fixture_data: Dict[str, str], ) -> None: trace = web3.parity.trace_replay_transaction(HexStr(parity_fixture_data['mined_txn_hash'])) @@ -57,7 +57,7 @@ def test_trace_replay_transaction( ) def test_trace_replay_block_transactions( - self, web3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str] + self, w3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str] ) -> None: trace = web3.parity.trace_replay_block_transactions(block_with_txn['number']) assert len(trace) > 0 @@ -65,7 +65,7 @@ def test_trace_replay_block_transactions( assert trace_0_action['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase'])) def test_traceReplayBlockTransactions_deprecated( - self, web3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str] + self, w3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str] ) -> None: with pytest.warns(DeprecationWarning, match='traceReplayBlockTransactions is deprecated in favor of ' @@ -76,27 +76,27 @@ def test_traceReplayBlockTransactions_deprecated( assert trace_0_action['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase'])) def test_trace_replay_block_without_transactions( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: trace = web3.parity.trace_replay_block_transactions(empty_block['number']) assert len(trace) == 0 - def test_trace_block(self, web3: "Web3", block_with_txn: BlockData) -> None: + def test_trace_block(self, w3: "Web3", block_with_txn: BlockData) -> None: trace = web3.parity.trace_block(block_with_txn['number']) assert trace[0]['blockNumber'] == block_with_txn['number'] - def test_traceBlock_deprecated(self, web3: "Web3", block_with_txn: BlockData) -> None: + def test_traceBlock_deprecated(self, w3: "Web3", block_with_txn: BlockData) -> None: with pytest.warns(DeprecationWarning, match='traceBlock is deprecated in favor of trace_block'): trace = web3.parity.traceBlock(block_with_txn['number']) assert trace[0]['blockNumber'] == block_with_txn['number'] - def test_trace_transaction(self, web3: "Web3", parity_fixture_data: Dict[str, str]) -> None: + def test_trace_transaction(self, w3: "Web3", parity_fixture_data: Dict[str, str]) -> None: trace = web3.parity.trace_transaction(HexStr(parity_fixture_data['mined_txn_hash'])) assert trace[0]['action']['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase'])) def test_traceTransaction_deprecated( - self, web3: "Web3", parity_fixture_data: Dict[str, str] + self, w3: "Web3", parity_fixture_data: Dict[str, str] ) -> None: with pytest.warns(DeprecationWarning, match="traceTransaction is deprecated in favor of trace_transaction"): @@ -104,7 +104,7 @@ def test_traceTransaction_deprecated( assert trace[0]['action']['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase'])) def test_traceCall_deprecated( - self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress + self, w3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress ) -> None: coinbase = web3.eth.coinbase txn_params = math_contract._prepare_transaction( @@ -121,7 +121,7 @@ def test_traceCall_deprecated( assert result == 18 def test_trace_call( - self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress + self, w3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress ) -> None: coinbase = web3.eth.coinbase txn_params = math_contract._prepare_transaction( @@ -136,7 +136,7 @@ def test_trace_call( assert result == 18 def test_trace_call_with_0_result( - self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress + self, w3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress ) -> None: coinbase = web3.eth.coinbase txn_params = math_contract._prepare_transaction( @@ -152,7 +152,7 @@ def test_trace_call_with_0_result( def test_trace_raw_transaction( self, - web3: "Web3", + w3: "Web3", raw_transaction: HexStr, funded_account_for_raw_txn: ChecksumAddress, ) -> None: @@ -165,7 +165,7 @@ def test_trace_raw_transaction( def test_trace_raw_transaction_deprecated( self, - web3: "Web3", + w3: "Web3", raw_transaction: HexStr, funded_account_for_raw_txn: ChecksumAddress, ) -> None: @@ -182,7 +182,7 @@ def test_trace_raw_transaction_deprecated( def test_trace_filter( self, - web3: "Web3", + w3: "Web3", txn_filter_params: ParityFilterParams, parity_fixture_data: Dict[str, str], ) -> None: @@ -192,7 +192,7 @@ def test_trace_filter( def test_traceFilter_deprecated( self, - web3: "Web3", + w3: "Web3", txn_filter_params: ParityFilterParams, parity_fixture_data: Dict[str, str], ) -> None: @@ -205,37 +205,37 @@ def test_traceFilter_deprecated( class ParityModuleTest: - def test_add_reserved_peer(self, web3: "Web3") -> None: + def test_add_reserved_peer(self, w3: "Web3") -> None: peer_addr = EnodeURI('enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30300') # noqa: E501 assert web3.parity.add_reserved_peer(peer_addr) - def test_addReservedPeer_deprecated(self, web3: "Web3") -> None: + def test_addReservedPeer_deprecated(self, w3: "Web3") -> None: peer_addr = EnodeURI('enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30300') # noqa: E501 with pytest.warns(DeprecationWarning, match='addReservedPeer is deprecated in favor of add_reserved_peer'): assert web3.parity.addReservedPeer(peer_addr) def test_list_storage_keys_no_support( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: keys = web3.parity.list_storage_keys(emitter_contract_address, 10, None) assert keys == [] def test_list_storage_keys( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: keys = web3.parity.list_storage_keys(emitter_contract_address, 10, None) assert keys == [] def test_listStorageKeys_deprecated( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning, match='listStorageKeys is deprecated in favor of list_storage_keys'): keys = web3.parity.listStorageKeys(emitter_contract_address, 10, None) assert keys == [] - def test_mode(self, web3: "Web3") -> None: + def test_mode(self, w3: "Web3") -> None: assert web3.parity.mode() is not None @@ -250,19 +250,19 @@ class ParitySetModuleTest: ('passive'), ] ) - def test_set_mode(self, web3: "Web3", mode: ParityMode) -> None: + def test_set_mode(self, w3: "Web3", mode: ParityMode) -> None: assert web3.parity.set_mode(mode) is True - def test_set_mode_deprecated(self, web3: "Web3", mode: ParityMode) -> None: + def test_set_mode_deprecated(self, w3: "Web3", mode: ParityMode) -> None: with pytest.warns(DeprecationWarning, match="setMode is deprecated in favor of set_mode"): assert web3.parity.setMode(mode) is True - def test_set_mode_with_bad_string(self, web3: "Web3") -> None: + def test_set_mode_with_bad_string(self, w3: "Web3") -> None: with pytest.raises(InvalidParityMode, match="Couldn't parse parameters: mode"): # type ignored b/c it's an invalid literal ParityMode web3.parity.set_mode('not a mode') # type: ignore - def test_set_mode_with_no_argument(self, web3: "Web3") -> None: + def test_set_mode_with_no_argument(self, w3: "Web3") -> None: with pytest.raises( InvalidParityMode, match='Invalid params: invalid length 0, expected a tuple of size 1.' diff --git a/web3/_utils/module_testing/personal_module.py b/web3/_utils/module_testing/personal_module.py index 20f3793dfc..b5213664a6 100644 --- a/web3/_utils/module_testing/personal_module.py +++ b/web3/_utils/module_testing/personal_module.py @@ -38,16 +38,16 @@ class GoEthereumPersonalModuleTest: - def test_personal_import_raw_key(self, web3: "Web3") -> None: + def test_personal_import_raw_key(self, w3: "Web3") -> None: actual = web3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD) assert actual == ADDRESS - def test_personal_importRawKey_deprecated(self, web3: "Web3") -> None: + def test_personal_importRawKey_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): actual = web3.geth.personal.importRawKey(SECOND_PRIVATE_KEY_HEX, PASSWORD) assert actual == SECOND_ADDRESS - def test_personal_list_accounts(self, web3: "Web3") -> None: + def test_personal_list_accounts(self, w3: "Web3") -> None: accounts = web3.geth.personal.list_accounts() assert is_list_like(accounts) assert len(accounts) > 0 @@ -57,7 +57,7 @@ def test_personal_list_accounts(self, web3: "Web3") -> None: in accounts )) - def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: + def test_personal_listAccounts_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): accounts = web3.geth.personal.listAccounts() assert is_list_like(accounts) @@ -68,7 +68,7 @@ def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: in accounts )) - def test_personal_list_wallets(self, web3: "Web3") -> None: + def test_personal_list_wallets(self, w3: "Web3") -> None: wallets = web3.geth.personal.list_wallets() assert is_list_like(wallets) assert len(wallets) > 0 @@ -78,13 +78,13 @@ def test_personal_list_wallets(self, web3: "Web3") -> None: assert is_string(wallets[0]['url']) def test_personal_lock_account( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: # TODO: how do we test this better? web3.geth.personal.lock_account(unlockable_account_dual_type) def test_personal_lockAccount_deprecated( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): # TODO: how do we test this better? @@ -92,7 +92,7 @@ def test_personal_lockAccount_deprecated( def test_personal_unlock_account_success( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -104,7 +104,7 @@ def test_personal_unlock_account_success( def test_personal_unlockAccount_success_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -116,30 +116,30 @@ def test_personal_unlockAccount_success_deprecated( assert result is True def test_personal_unlock_account_failure( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.raises(ValueError): web3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') def test_personal_unlockAccount_failure_deprecated( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): with pytest.raises(ValueError): web3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') - def test_personal_new_account(self, web3: "Web3") -> None: + def test_personal_new_account(self, w3: "Web3") -> None: new_account = web3.geth.personal.new_account(PASSWORD) assert is_checksum_address(new_account) - def test_personal_newAccount_deprecated(self, web3: "Web3") -> None: + def test_personal_newAccount_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): new_account = web3.geth.personal.newAccount(PASSWORD) assert is_checksum_address(new_account) def test_personal_send_transaction( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -163,7 +163,7 @@ def test_personal_send_transaction( def test_personal_sendTransaction_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -189,7 +189,7 @@ def test_personal_sendTransaction_deprecated( def test_personal_sign_and_ecrecover( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -204,7 +204,7 @@ def test_personal_sign_and_ecrecover( def test_personal_sign_and_ecrecover_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -223,7 +223,7 @@ def test_personal_sign_and_ecrecover_deprecated( ) def test_personal_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -283,7 +283,7 @@ def test_personal_sign_typed_data( @pytest.mark.xfail(reason="personal_signTypedData JSON RPC call has not been released in geth") def test_personal_sign_typed_data_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -344,7 +344,7 @@ def test_personal_sign_typed_data_deprecated( class ParityPersonalModuleTest(): - def test_personal_list_accounts(self, web3: "Web3") -> None: + def test_personal_list_accounts(self, w3: "Web3") -> None: accounts = web3.parity.personal.list_accounts() assert is_list_like(accounts) assert len(accounts) > 0 @@ -354,7 +354,7 @@ def test_personal_list_accounts(self, web3: "Web3") -> None: in accounts )) - def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: + def test_personal_listAccounts_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): accounts = web3.parity.personal.listAccounts() assert is_list_like(accounts) @@ -367,7 +367,7 @@ def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: def test_personal_unlock_account_success( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -380,7 +380,7 @@ def test_personal_unlock_account_success( def test_personal_unlockAccount_success_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -395,7 +395,7 @@ def test_personal_unlockAccount_success_deprecated( # Seems to be an issue with Parity since this should return False def test_personal_unlock_account_failure( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, ) -> None: result = web3.parity.personal.unlock_account( @@ -408,7 +408,7 @@ def test_personal_unlock_account_failure( # Seems to be an issue with Parity since this should return False def test_personal_unlockAccount_failure_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, ) -> None: with pytest.warns(DeprecationWarning): @@ -419,44 +419,44 @@ def test_personal_unlockAccount_failure_deprecated( ) assert result is True - def test_personal_new_account(self, web3: "Web3") -> None: + def test_personal_new_account(self, w3: "Web3") -> None: new_account = web3.parity.personal.new_account(PASSWORD) assert is_checksum_address(new_account) - def test_personal_newAccount_deprecated(self, web3: "Web3") -> None: + def test_personal_newAccount_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): new_account = web3.parity.personal.newAccount(PASSWORD) assert is_checksum_address(new_account) @pytest.mark.xfail(reason='this non-standard json-rpc method is not implemented on parity') def test_personal_lock_account( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: # method undefined in superclass super().test_personal_lock_account(web3, unlocked_account) # type: ignore @pytest.mark.xfail(reason='this non-standard json-rpc method is not implemented on parity') def test_personal_lockAccount_deprecated( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): # method undefined in superclass super().test_personal_lockAccount(web3, unlocked_account) # type: ignore @pytest.mark.xfail(reason='this non-standard json-rpc method is not implemented on parity') - def test_personal_import_raw_key(self, web3: "Web3") -> None: + def test_personal_import_raw_key(self, w3: "Web3") -> None: # method undefined in superclass super().test_personal_import_raw_key(web3) # type: ignore @pytest.mark.xfail(reason='this non-standard json-rpc method is not implemented on parity') - def test_personal_importRawKey_deprecated(self, web3: "Web3") -> None: + def test_personal_importRawKey_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): # method undefined in superclass super().test_personal_importRawKey_deprecated(web3) # type: ignore def test_personal_send_transaction( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -480,7 +480,7 @@ def test_personal_send_transaction( def test_personal_sendTransaction_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -505,7 +505,7 @@ def test_personal_sendTransaction_deprecated( def test_personal_sign_and_ecrecover( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -520,7 +520,7 @@ def test_personal_sign_and_ecrecover( def test_personal_sign_and_ecrecover_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -536,7 +536,7 @@ def test_personal_sign_and_ecrecover_deprecated( def test_personal_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -595,7 +595,7 @@ def test_personal_sign_typed_data( def test_personal_sign_typed_data_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -655,7 +655,7 @@ def test_personal_sign_typed_data_deprecated( def test_invalid_personal_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -708,7 +708,7 @@ def test_invalid_personal_sign_typed_data( def test_invalid_personal_sign_typed_data_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: diff --git a/web3/_utils/module_testing/version_module.py b/web3/_utils/module_testing/version_module.py index 69b7c907ed..820689334e 100644 --- a/web3/_utils/module_testing/version_module.py +++ b/web3/_utils/module_testing/version_module.py @@ -12,14 +12,14 @@ class VersionModuleTest: - def test_eth_protocol_version(self, web3: "Web3") -> None: + def test_eth_protocol_version(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): protocol_version = web3.eth.protocol_version assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_protocolVersion(self, web3: "Web3") -> None: + def test_eth_protocolVersion(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): protocol_version = web3.eth.protocolVersion diff --git a/web3/_utils/module_testing/web3_module.py b/web3/_utils/module_testing/web3_module.py index a8eb73f332..7b21a9b809 100644 --- a/web3/_utils/module_testing/web3_module.py +++ b/web3/_utils/module_testing/web3_module.py @@ -25,7 +25,7 @@ class Web3ModuleTest: - def test_web3_clientVersion(self, web3: Web3) -> None: + def test_web3_clientVersion(self, w3: Web3) -> None: client_version = web3.clientVersion self._check_web3_clientVersion(client_version) @@ -176,7 +176,7 @@ def _check_web3_clientVersion(self, client_version: str) -> NoReturn: ), ) def test_solidityKeccak( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[Any], expected: HexBytes + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[Any], expected: HexBytes ) -> None: if isinstance(expected, type) and issubclass(expected, Exception): with pytest.raises(expected): @@ -202,7 +202,7 @@ def test_solidityKeccak( ), ) def test_solidityKeccak_ens( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[str], expected: HexBytes + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[str], expected: HexBytes ) -> None: with ens_addresses(web3, { 'one.eth': ChecksumAddress( @@ -229,10 +229,10 @@ def test_solidityKeccak_ens( ) ) def test_solidityKeccak_same_number_of_types_and_values( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[Any] + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[Any] ) -> None: with pytest.raises(ValueError): web3.solidityKeccak(types, values) - def test_is_connected(self, web3: "Web3") -> None: + def test_is_connected(self, w3: "Web3") -> None: assert web3.isConnected() diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index e484960ffa..f4595aab5b 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -62,7 +62,7 @@ @curry -def fill_nonce(web3: "Web3", transaction: TxParams) -> TxParams: +def fill_nonce(w3: "Web3", transaction: TxParams) -> TxParams: if 'from' in transaction and 'nonce' not in transaction: return assoc( transaction, @@ -75,7 +75,7 @@ def fill_nonce(web3: "Web3", transaction: TxParams) -> TxParams: @curry -def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: +def fill_transaction_defaults(w3: "Web3", transaction: TxParams) -> TxParams: """ if web3 is None, fill as much as possible while offline """ @@ -94,7 +94,7 @@ def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: def wait_for_transaction_receipt( - web3: "Web3", txn_hash: _Hash32, timeout: float, poll_latency: float + w3: "Web3", txn_hash: _Hash32, timeout: float, poll_latency: float ) -> TxReceipt: with Timeout(timeout) as _timeout: while True: @@ -112,7 +112,7 @@ def wait_for_transaction_receipt( return txn_receipt -def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> Wei: +def get_block_gas_limit(w3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> Wei: if block_identifier is None: block_identifier = web3.eth.block_number block = web3.eth.get_block(block_identifier) @@ -120,7 +120,7 @@ def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier def get_buffered_gas_estimate( - web3: "Web3", transaction: TxParams, gas_buffer: Wei = Wei(100000) + w3: "Web3", transaction: TxParams, gas_buffer: Wei = Wei(100000) ) -> Wei: gas_estimate_transaction = cast(TxParams, dict(**transaction)) @@ -138,7 +138,7 @@ def get_buffered_gas_estimate( return Wei(min(gas_limit, gas_estimate + gas_buffer)) -def get_required_transaction(web3: "Web3", transaction_hash: _Hash32) -> TxData: +def get_required_transaction(w3: "Web3", transaction_hash: _Hash32) -> TxData: current_transaction = web3.eth.get_transaction(transaction_hash) if not current_transaction: raise ValueError('Supplied transaction with hash {} does not exist' @@ -180,7 +180,7 @@ def assert_valid_transaction_params(transaction_params: TxParams) -> None: def prepare_replacement_transaction( - web3: "Web3", + w3: "Web3", current_transaction: TxData, new_transaction: TxParams, gas_multiplier: float = 1.125 @@ -209,7 +209,7 @@ def prepare_replacement_transaction( def replace_transaction( - web3: "Web3", current_transaction: TxData, new_transaction: TxParams + w3: "Web3", current_transaction: TxData, new_transaction: TxParams ) -> HexBytes: new_transaction = prepare_replacement_transaction( web3, current_transaction, new_transaction diff --git a/web3/contract.py b/web3/contract.py index 340d384b46..f2785e6e44 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -154,9 +154,9 @@ class ContractFunctions: """Class containing contract function objects """ - def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: + def __init__(self, abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: self.abi = abi - self.web3 = web3 + self.w3 = web3 self.address = address if self.abi: @@ -228,7 +228,7 @@ class ContractEvents: """ - def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: + def __init__(self, abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: if abi: self.abi = abi self._events = filter_by_type('event', self.abi) @@ -293,7 +293,7 @@ class Contract: """ # set during class construction - web3: 'Web3' = None + w3: 'Web3' = None # instance level properties address: ChecksumAddress = None @@ -346,7 +346,7 @@ def __init__(self, address: Optional[ChecksumAddress] = None) -> None: self.receive = Contract.get_receive_function(self.abi, self.web3, self.address) @classmethod - def factory(cls, web3: 'Web3', class_name: Optional[str] = None, **kwargs: Any) -> 'Contract': + def factory(cls, w3: 'Web3', class_name: Optional[str] = None, **kwargs: Any) -> 'Contract': kwargs['web3'] = web3 @@ -530,7 +530,7 @@ def _find_matching_event_abi( @staticmethod def get_fallback_function( - abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None + abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None ) -> 'ContractFunction': if abi and fallback_func_abi_exists(abi): return ContractFunction.factory( @@ -544,7 +544,7 @@ def get_fallback_function( @staticmethod def get_receive_function( - abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None + abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None ) -> 'ContractFunction': if abi and receive_func_abi_exists(abi): return ContractFunction.factory( @@ -595,9 +595,9 @@ class ContractConstructor: Class for contract constructor API. """ def __init__( - self, web3: 'Web3', abi: ABI, bytecode: HexStr, *args: Any, **kwargs: Any + self, w3: 'Web3', abi: ABI, bytecode: HexStr, *args: Any, **kwargs: Any ) -> None: - self.web3 = web3 + self.w3 = web3 self.abi = abi self.bytecode = bytecode self.data_in_transaction = self._encode_data_in_transaction(*args, **kwargs) @@ -849,7 +849,7 @@ class ContractFunction: """ address: ChecksumAddress = None function_identifier: FunctionIdentifier = None - web3: 'Web3' = None + w3: 'Web3' = None contract_abi: ABI = None abi: ABIFunction = None transaction: TxParams = None @@ -1110,7 +1110,7 @@ class ContractEvent: """ address: ChecksumAddress = None event_name: str = None - web3: 'Web3' = None + w3: 'Web3' = None contract_abi: ABI = None abi: ABIEvent = None @@ -1368,11 +1368,11 @@ class ContractCaller: """ def __init__(self, abi: ABI, - web3: 'Web3', + w3: 'Web3', address: ChecksumAddress, transaction: Optional[TxParams] = None, block_identifier: BlockIdentifier = 'latest') -> None: - self.web3 = web3 + self.w3 = web3 self.address = address self.abi = abi self._functions = None @@ -1468,7 +1468,7 @@ def check_for_forbidden_api_filter_arguments( def call_contract_function( - web3: 'Web3', + w3: 'Web3', address: ChecksumAddress, normalizers: Tuple[Callable[..., Any], ...], function_identifier: FunctionIdentifier, @@ -1539,7 +1539,7 @@ def call_contract_function( return normalized_data -def parse_block_identifier(web3: 'Web3', block_identifier: BlockIdentifier) -> BlockIdentifier: +def parse_block_identifier(w3: 'Web3', block_identifier: BlockIdentifier) -> BlockIdentifier: if isinstance(block_identifier, int): return parse_block_identifier_int(web3, block_identifier) elif block_identifier in ['latest', 'earliest', 'pending']: @@ -1550,7 +1550,7 @@ def parse_block_identifier(web3: 'Web3', block_identifier: BlockIdentifier) -> B raise BlockNumberOutofRange -def parse_block_identifier_int(web3: 'Web3', block_identifier_int: int) -> BlockNumber: +def parse_block_identifier_int(w3: 'Web3', block_identifier_int: int) -> BlockNumber: if block_identifier_int >= 0: block_num = block_identifier_int else: @@ -1563,7 +1563,7 @@ def parse_block_identifier_int(web3: 'Web3', block_identifier_int: int) -> Block def transact_with_contract_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', function_name: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1591,7 +1591,7 @@ def transact_with_contract_function( def estimate_gas_for_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', fn_identifier: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1620,7 +1620,7 @@ def estimate_gas_for_function( def build_transaction_for_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', function_name: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1649,7 +1649,7 @@ def build_transaction_for_function( def find_functions_by_identifier( - contract_abi: ABI, web3: 'Web3', address: ChecksumAddress, callable_check: Callable[..., Any] + contract_abi: ABI, w3: 'Web3', address: ChecksumAddress, callable_check: Callable[..., Any] ) -> List[ContractFunction]: fns_abi = filter_by_type('function', contract_abi) return [ diff --git a/web3/gas_strategies/rpc.py b/web3/gas_strategies/rpc.py index 272c90ebe8..7b7818b2e4 100644 --- a/web3/gas_strategies/rpc.py +++ b/web3/gas_strategies/rpc.py @@ -12,7 +12,7 @@ ) -def rpc_gas_price_strategy(web3: Web3, +def rpc_gas_price_strategy(w3: Web3, transaction_params: Optional[TxParams] = None) -> Wei: """ A simple gas price strategy deriving it's value from the eth_gasPrice JSON-RPC call. diff --git a/web3/gas_strategies/time_based.py b/web3/gas_strategies/time_based.py index 4005435d0b..21ad83c13b 100644 --- a/web3/gas_strategies/time_based.py +++ b/web3/gas_strategies/time_based.py @@ -201,7 +201,7 @@ def construct_time_based_gas_price_strategy( and 100 means 100%. """ - def time_based_gas_price_strategy(web3: Web3, transaction_params: TxParams) -> Wei: + def time_based_gas_price_strategy(w3: Web3, transaction_params: TxParams) -> Wei: if weighted: avg_block_time = _get_weighted_avg_block_time(web3, sample_size=sample_size) else: diff --git a/web3/manager.py b/web3/manager.py index 9402096397..672e62731d 100644 --- a/web3/manager.py +++ b/web3/manager.py @@ -73,11 +73,11 @@ class RequestManager: def __init__( self, - web3: 'Web3', + w3: 'Web3', provider: Optional[BaseProvider] = None, middlewares: Optional[Sequence[Tuple[Middleware, str]]] = None ) -> None: - self.web3 = web3 + self.w3 = web3 self.pending_requests: Dict[UUID, ThreadWithReturn[RPCResponse]] = {} if middlewares is None: @@ -90,7 +90,7 @@ def __init__( else: self.provider = provider - web3: 'Web3' = None + w3: 'Web3' = None _provider = None @property @@ -103,7 +103,7 @@ def provider(self, provider: BaseProvider) -> None: @staticmethod def default_middlewares( - web3: 'Web3' + w3: 'Web3' ) -> List[Tuple[Middleware, str]]: """ List the default middlewares for the request manager. diff --git a/web3/method.py b/web3/method.py index 087902e974..9675817a4a 100644 --- a/web3/method.py +++ b/web3/method.py @@ -120,7 +120,7 @@ def __init__( result_formatters: Optional[Callable[..., TReturn]] = None, error_formatters: Optional[Callable[..., TReturn]] = None, method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None, - web3: Optional["Web3"] = None): + w3: Optional["Web3"] = None): self.json_rpc_method = json_rpc_method self.mungers = mungers or [default_munger] diff --git a/web3/middleware/__init__.py b/web3/middleware/__init__.py index 2e06da2d67..d860142de0 100644 --- a/web3/middleware/__init__.py +++ b/web3/middleware/__init__.py @@ -76,7 +76,7 @@ def combine_middlewares( middlewares: Sequence[Middleware], - web3: 'Web3', + w3: 'Web3', provider_request_fn: Callable[[RPCEndpoint, Any], Any] ) -> Callable[..., RPCResponse]: """ diff --git a/web3/middleware/attrdict.py b/web3/middleware/attrdict.py index 14f33e1bf1..16643ae4ac 100644 --- a/web3/middleware/attrdict.py +++ b/web3/middleware/attrdict.py @@ -24,7 +24,7 @@ def attrdict_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: """ Converts any result which is a dictionary into an a diff --git a/web3/middleware/cache.py b/web3/middleware/cache.py index f68f626b4c..9354050097 100644 --- a/web3/middleware/cache.py +++ b/web3/middleware/cache.py @@ -111,7 +111,7 @@ def construct_simple_cache_middleware( cached. """ def simple_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], RPCResponse], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], RPCResponse], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() lock = threading.Lock() @@ -215,7 +215,7 @@ def construct_time_based_cache_middleware( cached. """ def time_based_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() lock = threading.Lock() @@ -355,7 +355,7 @@ def construct_latest_block_based_cache_middleware( block time. """ def latest_block_based_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() block_info: BlockInfoCache = {} diff --git a/web3/middleware/exception_handling.py b/web3/middleware/exception_handling.py index a74cc19694..c2781456a9 100644 --- a/web3/middleware/exception_handling.py +++ b/web3/middleware/exception_handling.py @@ -30,7 +30,7 @@ def construct_exception_handler_middleware( method_handlers = {} def exception_handler_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in method_handlers: diff --git a/web3/middleware/exception_retry_request.py b/web3/middleware/exception_retry_request.py index 887b45c68d..4352026d8a 100644 --- a/web3/middleware/exception_retry_request.py +++ b/web3/middleware/exception_retry_request.py @@ -89,7 +89,7 @@ def check_if_retry_on_failure(method: RPCEndpoint) -> bool: def exception_retry_middleware( make_request: Callable[[RPCEndpoint, Any], RPCResponse], - web3: "Web3", + w3: "Web3", errors: Collection[Type[BaseException]], retries: int = 5, ) -> Callable[[RPCEndpoint, Any], RPCResponse]: @@ -115,7 +115,7 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: def http_retry_request_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], Any]: return exception_retry_middleware( make_request, diff --git a/web3/middleware/fixture.py b/web3/middleware/fixture.py index b54d0902a8..fa73aa3f1c 100644 --- a/web3/middleware/fixture.py +++ b/web3/middleware/fixture.py @@ -21,7 +21,7 @@ def construct_fixture_middleware(fixtures: Dict[RPCEndpoint, Any]) -> Middleware which is found in the provided fixtures. """ def fixture_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in fixtures: @@ -43,7 +43,7 @@ def construct_result_generator_middleware( functions with the signature `fn(method, params)`. """ def result_generator_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in result_generators: @@ -65,7 +65,7 @@ def construct_error_generator_middleware( functions with the signature `fn(method, params)`. """ def error_generator_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in error_generators: diff --git a/web3/middleware/gas_price_strategy.py b/web3/middleware/gas_price_strategy.py index 6593356128..1b5b66f9fd 100644 --- a/web3/middleware/gas_price_strategy.py +++ b/web3/middleware/gas_price_strategy.py @@ -18,7 +18,7 @@ def gas_price_strategy_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: """ Includes a gas price using the gas price strategy diff --git a/web3/middleware/normalize_errors.py b/web3/middleware/normalize_errors.py index fce1032446..8ed82b8bcd 100644 --- a/web3/middleware/normalize_errors.py +++ b/web3/middleware/normalize_errors.py @@ -19,7 +19,7 @@ def normalize_errors_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: result = make_request(method, params) diff --git a/web3/middleware/simulate_unmined_transaction.py b/web3/middleware/simulate_unmined_transaction.py index e36300c9ff..9e74b20c06 100644 --- a/web3/middleware/simulate_unmined_transaction.py +++ b/web3/middleware/simulate_unmined_transaction.py @@ -22,7 +22,7 @@ def unmined_receipt_simulator_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: Web3 + make_request: Callable[[RPCEndpoint, Any], Any], w3: Web3 ) -> Callable[[RPCEndpoint, Any], RPCResponse]: receipt_counters: DefaultDict[Hash32, TxReceipt] = collections.defaultdict( # type: ignore # noqa: F821, E501 itertools.count diff --git a/web3/middleware/stalecheck.py b/web3/middleware/stalecheck.py index 86711ee67c..4148cb2ece 100644 --- a/web3/middleware/stalecheck.py +++ b/web3/middleware/stalecheck.py @@ -47,7 +47,7 @@ def make_stalecheck_middleware( raise ValueError("You must set a positive allowable_delay in seconds for this middleware") def stalecheck_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache: Dict[str, BlockData] = {'latest': None} diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 2e956655f4..22b3306542 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -50,7 +50,7 @@ @curry -def validate_chain_id(web3: "Web3", chain_id: int) -> int: +def validate_chain_id(w3: "Web3", chain_id: int) -> int: if to_integer_if_hex(chain_id) == web3.eth.chain_id: return chain_id else: @@ -84,7 +84,7 @@ def transaction_normalizer(transaction: TxParams) -> TxParams: return dissoc(transaction, 'chainId') -def transaction_param_validator(web3: "Web3") -> Callable[..., Any]: +def transaction_param_validator(w3: "Web3") -> Callable[..., Any]: transactions_params_validators = { "chainId": apply_formatter_if( # Bypass `validate_chain_id` if chainId can't be determined @@ -110,7 +110,7 @@ def transaction_param_validator(web3: "Web3") -> Callable[..., Any]: @curry -def chain_id_validator(web3: "Web3") -> Callable[..., Any]: +def chain_id_validator(w3: "Web3") -> Callable[..., Any]: return compose( apply_formatter_at_index(transaction_normalizer, 0), transaction_param_validator(web3) diff --git a/web3/module.py b/web3/module.py index 1d3f6de4fa..f8de45eacc 100644 --- a/web3/module.py +++ b/web3/module.py @@ -78,10 +78,10 @@ async def caller(*args: Any, **kwargs: Any) -> RPCResponse: class Module: is_async = False - def __init__(self, web3: "Web3") -> None: + def __init__(self, w3: "Web3") -> None: if self.is_async: self.retrieve_caller_fn = retrieve_async_method_call_fn(web3, self) else: self.retrieve_caller_fn = retrieve_blocking_method_call_fn(web3, self) - self.web3 = web3 + self.w3 = web3 self.codec: ABICodec = web3.codec diff --git a/web3/pm.py b/web3/pm.py index 5257db22bd..2a897bd335 100644 --- a/web3/pm.py +++ b/web3/pm.py @@ -554,7 +554,7 @@ def _validate_set_registry(self) -> None: ) def _validate_set_ens(self) -> None: - if not self.web3: + if not self.w3: raise InvalidAddress( "Could not look up ENS address because no web3 " "connection available" ) diff --git a/web3/providers/base.py b/web3/providers/base.py index 4f426934d5..cd5adef47e 100644 --- a/web3/providers/base.py +++ b/web3/providers/base.py @@ -47,7 +47,7 @@ def middlewares( self._middlewares = tuple(values) # type: ignore def request_func( - self, web3: "Web3", outer_middlewares: MiddlewareOnion + self, w3: "Web3", outer_middlewares: MiddlewareOnion ) -> Callable[..., RPCResponse]: """ @param outer_middlewares is an iterable of middlewares, ordered by first to execute @@ -65,7 +65,7 @@ def request_func( return self._request_func_cache[-1] def _generate_request_func( - self, web3: "Web3", middlewares: Sequence[Middleware] + self, w3: "Web3", middlewares: Sequence[Middleware] ) -> Callable[..., RPCResponse]: return combine_middlewares( middlewares=middlewares, diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py index ab7950d96b..46ed988aa2 100644 --- a/web3/providers/eth_tester/middleware.py +++ b/web3/providers/eth_tester/middleware.py @@ -283,7 +283,7 @@ def is_hexstr(value: Any) -> bool: ) -def guess_from(web3: "Web3", transaction: TxParams) -> ChecksumAddress: +def guess_from(w3: "Web3", transaction: TxParams) -> ChecksumAddress: coinbase = web3.eth.coinbase if coinbase is not None: return coinbase @@ -297,13 +297,13 @@ def guess_from(web3: "Web3", transaction: TxParams) -> ChecksumAddress: return None -def guess_gas(web3: "Web3", transaction: TxParams) -> Wei: +def guess_gas(w3: "Web3", transaction: TxParams) -> Wei: return Wei(web3.eth.estimate_gas(transaction) * 2) @curry def fill_default( - field: str, guess_func: Callable[..., Any], web3: "Web3", transaction: TxParams + field: str, guess_func: Callable[..., Any], w3: "Web3", transaction: TxParams ) -> TxParams: # type ignored b/c TxParams keys must be string literal types if field in transaction and transaction[field] is not None: # type: ignore @@ -314,7 +314,7 @@ def fill_default( def default_transaction_fields_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: fill_default_from = fill_default('from', guess_from, web3) fill_default_gas = fill_default('gas', guess_gas, web3)