diff --git a/conftest.py b/conftest.py index d4459ef7e2..4f4307c128 100644 --- a/conftest.py +++ b/conftest.py @@ -2,13 +2,15 @@ import time import warnings +from web3._utils.threads import ( + Timeout, +) +from web3.main import ( + Web3, +) from web3.providers.eth_tester import ( EthereumTesterProvider, ) -from web3.utils.threads import ( - Timeout, -) -from web3.main import Web3 class PollDelayCounter: diff --git a/tests/conftest.py b/tests/conftest.py index 7cf42a0d00..a152f276a2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ to_bytes, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( identity, ) diff --git a/tests/core/caching-utils/test_generate_cache_key.py b/tests/core/caching-utils/test_generate_cache_key.py index a678792c48..73c425dc3f 100644 --- a/tests/core/caching-utils/test_generate_cache_key.py +++ b/tests/core/caching-utils/test_generate_cache_key.py @@ -8,7 +8,7 @@ strategies as st, ) -from web3.utils.caching import ( +from web3._utils.caching import ( generate_cache_key, ) diff --git a/tests/core/contracts/test_args_and_kwargs_merger.py b/tests/core/contracts/test_args_and_kwargs_merger.py index a1137c847c..eeb9876702 100644 --- a/tests/core/contracts/test_args_and_kwargs_merger.py +++ b/tests/core/contracts/test_args_and_kwargs_merger.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( merge_args_and_kwargs, ) diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index d7ab9c8d42..a6e1dcbce2 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -4,7 +4,7 @@ HexBytes, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, curry, ) diff --git a/tests/core/contracts/test_contract_buildTransaction.py b/tests/core/contracts/test_contract_buildTransaction.py index 6707399ff7..935f3de537 100644 --- a/tests/core/contracts/test_contract_buildTransaction.py +++ b/tests/core/contracts/test_contract_buildTransaction.py @@ -2,7 +2,7 @@ import pytest -from web3.utils.toolz import ( +from web3._utils.toolz import ( dissoc, ) diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 907a60af2e..b5d2005e6d 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -13,6 +13,12 @@ HexBytes, ) +from web3._utils.ens import ( + contract_ens_addresses, +) +from web3._utils.toolz import ( + identity, +) from web3.exceptions import ( BadFunctionCallOutput, BlockNumberOutofRange, @@ -21,12 +27,6 @@ NoABIFunctionsFound, ValidationError, ) -from web3.utils.ens import ( - contract_ens_addresses, -) -from web3.utils.toolz import ( - identity, -) # Ignore warning in pyethereum 1.6 - will go away with the upgrade pytestmark = pytest.mark.filterwarnings("ignore:implicit cast from 'char *'") diff --git a/tests/core/contracts/test_contract_init.py b/tests/core/contracts/test_contract_init.py index c70b80ceab..faaa46af60 100644 --- a/tests/core/contracts/test_contract_init.py +++ b/tests/core/contracts/test_contract_init.py @@ -1,13 +1,13 @@ import pytest +from web3._utils.ens import ( + contract_ens_addresses, + ens_addresses, +) from web3.exceptions import ( BadFunctionCallOutput, NameNotFound, ) -from web3.utils.ens import ( - contract_ens_addresses, - ens_addresses, -) @pytest.fixture() diff --git a/tests/core/contracts/test_contract_method_to_argument_matching.py b/tests/core/contracts/test_contract_method_to_argument_matching.py index dde4a465f7..2d6e8d2b94 100644 --- a/tests/core/contracts/test_contract_method_to_argument_matching.py +++ b/tests/core/contracts/test_contract_method_to_argument_matching.py @@ -1,15 +1,15 @@ import json import pytest -from web3.exceptions import ( - ValidationError, -) -from web3.utils.abi import ( +from web3._utils.abi import ( get_abi_input_types, ) -from web3.utils.function_identifiers import ( +from web3._utils.function_identifiers import ( FallbackFn, ) +from web3.exceptions import ( + ValidationError, +) SINGLE_FN_NO_ARGS = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"}]') # noqa: E501 SINGLE_FN_ONE_ARG = json.loads('[{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"}]') # noqa: E501 diff --git a/tests/core/contracts/test_contract_transact_interface.py b/tests/core/contracts/test_contract_transact_interface.py index 106221250d..097b391989 100644 --- a/tests/core/contracts/test_contract_transact_interface.py +++ b/tests/core/contracts/test_contract_transact_interface.py @@ -6,7 +6,7 @@ to_bytes, ) -from web3.utils.empty import ( +from web3._utils.empty import ( empty, ) diff --git a/tests/core/contracts/test_extracting_event_data.py b/tests/core/contracts/test_extracting_event_data.py index 6db411c809..fcd8cdcc76 100644 --- a/tests/core/contracts/test_extracting_event_data.py +++ b/tests/core/contracts/test_extracting_event_data.py @@ -4,7 +4,7 @@ is_same_address, ) -from web3.utils.events import ( +from web3._utils.events import ( get_event_data, ) diff --git a/tests/core/contracts/test_extracting_event_data_old.py b/tests/core/contracts/test_extracting_event_data_old.py index 1acad28b46..9d5a79e7f1 100644 --- a/tests/core/contracts/test_extracting_event_data_old.py +++ b/tests/core/contracts/test_extracting_event_data_old.py @@ -4,7 +4,7 @@ is_same_address, ) -from web3.utils.events import ( +from web3._utils.events import ( get_event_data, ) diff --git a/tests/core/core/block-utils/test_select_method_for_block_identifier.py b/tests/core/core/block-utils/test_select_method_for_block_identifier.py index dd4bb324a8..3a0c188032 100644 --- a/tests/core/core/block-utils/test_select_method_for_block_identifier.py +++ b/tests/core/core/block-utils/test_select_method_for_block_identifier.py @@ -1,9 +1,9 @@ import pytest -from web3.utils.blocks import ( +from web3._utils.blocks import ( select_method_for_block_identifier, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( partial, ) diff --git a/tests/core/empty-object/test_empty_object_is_falsy.py b/tests/core/empty-object/test_empty_object_is_falsy.py index 8db269243a..e9aaaf26b8 100644 --- a/tests/core/empty-object/test_empty_object_is_falsy.py +++ b/tests/core/empty-object/test_empty_object_is_falsy.py @@ -1,4 +1,4 @@ -from web3.utils.empty import ( +from web3._utils.empty import ( empty, ) diff --git a/tests/core/eth-module/test_accounts.py b/tests/core/eth-module/test_accounts.py index 774fb8e35f..8654b8bb31 100644 --- a/tests/core/eth-module/test_accounts.py +++ b/tests/core/eth-module/test_accounts.py @@ -16,16 +16,16 @@ Account, Web3, ) -from web3.providers.eth_tester import ( - EthereumTesterProvider, -) -from web3.utils.encoding import ( +from web3._utils.encoding import ( to_bytes, to_hex, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( dissoc, ) +from web3.providers.eth_tester import ( + EthereumTesterProvider, +) # from https://github.com/ethereum/tests/blob/3930ca3a9a377107d5792b3e7202f79c688f1a67/BasicTests/txtest.json # noqa: 501 ETH_TEST_TRANSACTIONS = [ diff --git a/tests/core/filtering/test_existing_filter_instance.py b/tests/core/filtering/test_existing_filter_instance.py index 2b5d494a8c..9c73428bdd 100644 --- a/tests/core/filtering/test_existing_filter_instance.py +++ b/tests/core/filtering/test_existing_filter_instance.py @@ -1,11 +1,11 @@ import pytest +from web3._utils.threads import ( + Timeout, +) from web3.providers.eth_tester import ( EthereumTesterProvider, ) -from web3.utils.threads import ( - Timeout, -) @pytest.fixture() diff --git a/tests/core/filtering/test_filter_against_latest_blocks.py b/tests/core/filtering/test_filter_against_latest_blocks.py index 6b2896d063..85d9fe20e6 100644 --- a/tests/core/filtering/test_filter_against_latest_blocks.py +++ b/tests/core/filtering/test_filter_against_latest_blocks.py @@ -1,9 +1,9 @@ +from web3._utils.threads import ( + Timeout, +) from web3.providers.eth_tester import ( EthereumTesterProvider, ) -from web3.utils.threads import ( - Timeout, -) def test_sync_filter_against_latest_blocks(web3, sleep_interval, wait_for_block): diff --git a/tests/core/filtering/test_filter_against_pending_transactions.py b/tests/core/filtering/test_filter_against_pending_transactions.py index b290051313..abba412d64 100644 --- a/tests/core/filtering/test_filter_against_pending_transactions.py +++ b/tests/core/filtering/test_filter_against_pending_transactions.py @@ -5,7 +5,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/filtering/test_filter_against_transaction_logs.py b/tests/core/filtering/test_filter_against_transaction_logs.py index 10e34062c3..b0c13a03ca 100644 --- a/tests/core/filtering/test_filter_against_transaction_logs.py +++ b/tests/core/filtering/test_filter_against_transaction_logs.py @@ -5,7 +5,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/middleware/test_latest_block_based_cache_middleware.py b/tests/core/middleware/test_latest_block_based_cache_middleware.py index 40734a52cd..8d0c30c6c2 100644 --- a/tests/core/middleware/test_latest_block_based_cache_middleware.py +++ b/tests/core/middleware/test_latest_block_based_cache_middleware.py @@ -10,6 +10,9 @@ ) from web3 import Web3 +from web3._utils.caching import ( + generate_cache_key, +) from web3.middleware import ( # noqa: F401 construct_error_generator_middleware, construct_latest_block_based_cache_middleware, @@ -18,9 +21,6 @@ from web3.providers.base import ( BaseProvider, ) -from web3.utils.caching import ( - generate_cache_key, -) @pytest.fixture diff --git a/tests/core/middleware/test_simple_cache_middleware.py b/tests/core/middleware/test_simple_cache_middleware.py index 86126e1b0c..2b1138de31 100644 --- a/tests/core/middleware/test_simple_cache_middleware.py +++ b/tests/core/middleware/test_simple_cache_middleware.py @@ -3,6 +3,9 @@ import uuid from web3 import Web3 +from web3._utils.caching import ( + generate_cache_key, +) from web3.middleware import ( construct_error_generator_middleware, construct_result_generator_middleware, @@ -11,9 +14,6 @@ from web3.providers.base import ( BaseProvider, ) -from web3.utils.caching import ( - generate_cache_key, -) @pytest.fixture diff --git a/tests/core/middleware/test_time_based_cache_middleware.py b/tests/core/middleware/test_time_based_cache_middleware.py index b10621aa86..0ea675209b 100644 --- a/tests/core/middleware/test_time_based_cache_middleware.py +++ b/tests/core/middleware/test_time_based_cache_middleware.py @@ -4,6 +4,9 @@ import uuid from web3 import Web3 +from web3._utils.caching import ( + generate_cache_key, +) from web3.middleware import ( # noqa: F401 construct_error_generator_middleware, construct_result_generator_middleware, @@ -12,9 +15,6 @@ from web3.providers.base import ( BaseProvider, ) -from web3.utils.caching import ( - generate_cache_key, -) @pytest.fixture diff --git a/tests/core/middleware/test_transaction_signing.py b/tests/core/middleware/test_transaction_signing.py index 18d6b33f5e..c46f24ed27 100644 --- a/tests/core/middleware/test_transaction_signing.py +++ b/tests/core/middleware/test_transaction_signing.py @@ -11,6 +11,11 @@ ) from web3 import Web3 +from web3._utils.toolz import ( + identity, + merge, + valfilter, +) from web3.exceptions import ( InvalidAddress, ) @@ -27,11 +32,6 @@ from web3.providers.eth_tester import ( EthereumTesterProvider, ) -from web3.utils.toolz import ( - identity, - merge, - valfilter, -) PRIVATE_KEY_1 = to_bytes( hexstr='0x6a8b4de52b288e111c14e1c4b868bc125d325d40331d86d875a3467dd44bf829') diff --git a/tests/core/mining-module/test_miner_setExtra.py b/tests/core/mining-module/test_miner_setExtra.py index e18036e570..2bfd4f8d76 100644 --- a/tests/core/mining-module/test_miner_setExtra.py +++ b/tests/core/mining-module/test_miner_setExtra.py @@ -7,7 +7,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/mining-module/test_miner_setGasPrice.py b/tests/core/mining-module/test_miner_setGasPrice.py index 3ec75f8c4b..7dc4d6c9a4 100644 --- a/tests/core/mining-module/test_miner_setGasPrice.py +++ b/tests/core/mining-module/test_miner_setGasPrice.py @@ -4,7 +4,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/mining-module/test_miner_start.py b/tests/core/mining-module/test_miner_start.py index f00ceeed0a..d260d373df 100644 --- a/tests/core/mining-module/test_miner_start.py +++ b/tests/core/mining-module/test_miner_start.py @@ -4,7 +4,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/mining-module/test_miner_stop.py b/tests/core/mining-module/test_miner_stop.py index 344a646293..4f2f128855 100644 --- a/tests/core/mining-module/test_miner_stop.py +++ b/tests/core/mining-module/test_miner_stop.py @@ -4,7 +4,7 @@ flaky, ) -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/txpool-module/test_txpool_content.py b/tests/core/txpool-module/test_txpool_content.py index 0816de80e6..7346a34421 100644 --- a/tests/core/txpool-module/test_txpool_content.py +++ b/tests/core/txpool-module/test_txpool_content.py @@ -1,6 +1,6 @@ import random -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/txpool-module/test_txpool_inspect.py b/tests/core/txpool-module/test_txpool_inspect.py index d5a162cbf6..77ffd07fd9 100644 --- a/tests/core/txpool-module/test_txpool_inspect.py +++ b/tests/core/txpool-module/test_txpool_inspect.py @@ -1,6 +1,6 @@ import random -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) diff --git a/tests/core/utilities/test_abi.py b/tests/core/utilities/test_abi.py index 0a9d492279..571dd58583 100644 --- a/tests/core/utilities/test_abi.py +++ b/tests/core/utilities/test_abi.py @@ -1,11 +1,11 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( abi_data_tree, map_abi_data, ) -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( BASE_RETURN_NORMALIZERS, ) diff --git a/tests/core/utilities/test_abi_filter_by_abi_name.py b/tests/core/utilities/test_abi_filter_by_abi_name.py index 4b907f8b09..cf7c4d1963 100644 --- a/tests/core/utilities/test_abi_filter_by_abi_name.py +++ b/tests/core/utilities/test_abi_filter_by_abi_name.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( filter_by_name, ) diff --git a/tests/core/utilities/test_abi_filtering_by_argument_name.py b/tests/core/utilities/test_abi_filtering_by_argument_name.py index 4d76d98da3..2baac9e355 100644 --- a/tests/core/utilities/test_abi_filtering_by_argument_name.py +++ b/tests/core/utilities/test_abi_filtering_by_argument_name.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( filter_by_argument_name, ) diff --git a/tests/core/utilities/test_abi_is_encodable.py b/tests/core/utilities/test_abi_is_encodable.py index e18130d9e9..5ac171788b 100644 --- a/tests/core/utilities/test_abi_is_encodable.py +++ b/tests/core/utilities/test_abi_is_encodable.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( is_encodable, ) diff --git a/tests/core/utilities/test_construct_data_filter_regex.py b/tests/core/utilities/test_construct_data_filter_regex.py index f6eef8dda7..d137141244 100644 --- a/tests/core/utilities/test_construct_data_filter_regex.py +++ b/tests/core/utilities/test_construct_data_filter_regex.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.filters import ( +from web3._utils.filters import ( construct_data_filter_regex, ) diff --git a/tests/core/utilities/test_construct_event_data_set.py b/tests/core/utilities/test_construct_event_data_set.py index 23b6607c61..0cc783f1ed 100644 --- a/tests/core/utilities/test_construct_event_data_set.py +++ b/tests/core/utilities/test_construct_event_data_set.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.events import ( +from web3._utils.events import ( construct_event_data_set, ) diff --git a/tests/core/utilities/test_construct_event_filter_params.py b/tests/core/utilities/test_construct_event_filter_params.py index 244cd4750b..956e35a5e7 100644 --- a/tests/core/utilities/test_construct_event_filter_params.py +++ b/tests/core/utilities/test_construct_event_filter_params.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.filters import ( +from web3._utils.filters import ( construct_event_filter_params, ) diff --git a/tests/core/utilities/test_construct_event_topics.py b/tests/core/utilities/test_construct_event_topics.py index 75b8d52691..3bc4b5fafa 100644 --- a/tests/core/utilities/test_construct_event_topics.py +++ b/tests/core/utilities/test_construct_event_topics.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.events import ( +from web3._utils.events import ( construct_event_topic_set, ) diff --git a/tests/core/utilities/test_datatypes.py b/tests/core/utilities/test_datatypes.py index f10d1e6d6d..754b4316d8 100644 --- a/tests/core/utilities/test_datatypes.py +++ b/tests/core/utilities/test_datatypes.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.datatypes import ( +from web3._utils.datatypes import ( PropertyCheckingFactory, ) diff --git a/tests/core/utilities/test_decorators.py b/tests/core/utilities/test_decorators.py index af377bc41f..b1a10d4b3d 100644 --- a/tests/core/utilities/test_decorators.py +++ b/tests/core/utilities/test_decorators.py @@ -1,9 +1,9 @@ import time -from web3.utils.decorators import ( +from web3._utils.decorators import ( reject_recursive_repeats, ) -from web3.utils.threads import ( +from web3._utils.threads import ( spawn, ) diff --git a/tests/core/utilities/test_encoding.py b/tests/core/utilities/test_encoding.py index 0164737ac2..ebfeb9164b 100644 --- a/tests/core/utilities/test_encoding.py +++ b/tests/core/utilities/test_encoding.py @@ -16,10 +16,7 @@ strategies as st, ) -from web3.providers import ( - JSONBaseProvider, -) -from web3.utils.encoding import ( +from web3._utils.encoding import ( FriendlyJsonSerde as FriendlyJson, hex_encode_abi_type, hexstr_if_str, @@ -27,9 +24,12 @@ to_hex, to_int, ) -from web3.utils.hypothesis import ( +from web3._utils.hypothesis import ( hexstr_strategy, ) +from web3.providers import ( + JSONBaseProvider, +) @pytest.mark.parametrize( diff --git a/tests/core/utilities/test_formatters.py b/tests/core/utilities/test_formatters.py index 3107c4bc25..6d74a1605b 100644 --- a/tests/core/utilities/test_formatters.py +++ b/tests/core/utilities/test_formatters.py @@ -1,7 +1,7 @@ import pytest -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatters_to_dict, map_collection, recursive_map, diff --git a/tests/core/utilities/test_is_predefined_block_number.py b/tests/core/utilities/test_is_predefined_block_number.py index 3bffc45ba5..95782ea4a6 100644 --- a/tests/core/utilities/test_is_predefined_block_number.py +++ b/tests/core/utilities/test_is_predefined_block_number.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.blocks import ( +from web3._utils.blocks import ( is_predefined_block_number, ) diff --git a/tests/core/utilities/test_is_probably_enum.py b/tests/core/utilities/test_is_probably_enum.py index e5139e682d..6b37b9b3fc 100644 --- a/tests/core/utilities/test_is_probably_enum.py +++ b/tests/core/utilities/test_is_probably_enum.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( is_probably_enum, ) diff --git a/tests/core/utilities/test_is_recognized_type.py b/tests/core/utilities/test_is_recognized_type.py index 013bd073de..679655e983 100644 --- a/tests/core/utilities/test_is_recognized_type.py +++ b/tests/core/utilities/test_is_recognized_type.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.abi import ( +from web3._utils.abi import ( is_address_type, is_array_type, is_bool_type, diff --git a/tests/core/utilities/test_math.py b/tests/core/utilities/test_math.py index f9331266ae..8495a7f06a 100644 --- a/tests/core/utilities/test_math.py +++ b/tests/core/utilities/test_math.py @@ -5,12 +5,12 @@ strategies as st, ) +from web3._utils.math import ( + percentile, +) from web3.exceptions import ( InsufficientData, ) -from web3.utils.math import ( - percentile, -) values = range(100) diff --git a/tests/core/utilities/test_prepare_transaction_replacement.py b/tests/core/utilities/test_prepare_transaction_replacement.py index 209453f0c3..e57b103aca 100644 --- a/tests/core/utilities/test_prepare_transaction_replacement.py +++ b/tests/core/utilities/test_prepare_transaction_replacement.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.transactions import ( +from web3._utils.transactions import ( prepare_replacement_transaction, ) diff --git a/tests/core/utilities/test_threads.py b/tests/core/utilities/test_threads.py index 0058eec0a5..56f7254375 100644 --- a/tests/core/utilities/test_threads.py +++ b/tests/core/utilities/test_threads.py @@ -1,7 +1,7 @@ import pytest import time -from web3.utils.threads import ( +from web3._utils.threads import ( ThreadWithReturn, Timeout, spawn, diff --git a/tests/core/utilities/test_valid_transaction_params.py b/tests/core/utilities/test_valid_transaction_params.py index f88a96c241..171699186b 100644 --- a/tests/core/utilities/test_valid_transaction_params.py +++ b/tests/core/utilities/test_valid_transaction_params.py @@ -1,6 +1,6 @@ import pytest -from web3.utils.transactions import ( +from web3._utils.transactions import ( assert_valid_transaction_params, extract_valid_transaction_params, ) diff --git a/tests/core/utilities/test_validation.py b/tests/core/utilities/test_validation.py index 618bcb5267..0dfe5359ee 100644 --- a/tests/core/utilities/test_validation.py +++ b/tests/core/utilities/test_validation.py @@ -4,15 +4,15 @@ to_bytes, ) -from web3.exceptions import ( - InvalidAddress, -) -from web3.utils.validation import ( +from web3._utils.validation import ( validate_abi, validate_abi_type, validate_abi_value, validate_address, ) +from web3.exceptions import ( + InvalidAddress, +) ABI = [ { diff --git a/tests/generate_go_ethereum_fixture.py b/tests/generate_go_ethereum_fixture.py index dc853a1e19..bc212adf73 100644 --- a/tests/generate_go_ethereum_fixture.py +++ b/tests/generate_go_ethereum_fixture.py @@ -23,16 +23,16 @@ ) from web3 import Web3 -from web3.utils.module_testing.emitter_contract import ( +from web3._utils.module_testing.emitter_contract import ( EMITTER_ABI, EMITTER_BYTECODE, EMITTER_ENUM, ) -from web3.utils.module_testing.math_contract import ( +from web3._utils.module_testing.math_contract import ( MATH_ABI, MATH_BYTECODE, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( merge, valmap, ) diff --git a/tests/integration/README.md b/tests/integration/README.md index 9811a6ccec..f5f8d5fea9 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -39,7 +39,7 @@ A block as returned by `web3.eth.getBlock` that has a single transaction. #### `math_contract` An deployed Contract instance of the *Math* contract found in -`web3.utils.module_testing.math_contract`. +`web3._utils.module_testing.math_contract`. #### `unlocked_account` @@ -66,7 +66,7 @@ The transaction hash of a transaction which has been mined. #### `emitter_contract` An deployed Contract instance of the *Emitter* contract found in -`web3.utils.module_testing.emitter_contract`. +`web3._utils.module_testing.emitter_contract`. #### `block_with_txn_with_log` diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 055d983220..d703917b7f 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,11 +1,11 @@ import asyncio import pytest -from web3.utils.module_testing.emitter_contract import ( +from web3._utils.module_testing.emitter_contract import ( EMITTER_ABI, EMITTER_BYTECODE, ) -from web3.utils.module_testing.math_contract import ( +from web3._utils.module_testing.math_contract import ( MATH_ABI, MATH_BYTECODE, ) diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index ca89bc5610..a45e41204a 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -12,16 +12,16 @@ import common from web3 import Web3 -from web3.utils.module_testing.emitter_contract import ( +from web3._utils.module_testing.emitter_contract import ( EMITTER_ABI, EMITTER_BYTECODE, EMITTER_ENUM, ) -from web3.utils.module_testing.math_contract import ( +from web3._utils.module_testing.math_contract import ( MATH_ABI, MATH_BYTECODE, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( merge, ) diff --git a/tests/integration/generate_fixtures/parity.py b/tests/integration/generate_fixtures/parity.py index 456eec358c..b5ced1d000 100644 --- a/tests/integration/generate_fixtures/parity.py +++ b/tests/integration/generate_fixtures/parity.py @@ -13,7 +13,7 @@ import common import go_ethereum from web3 import Web3 -from web3.utils.toolz import ( +from web3._utils.toolz import ( merge, ) diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 4f27dd1243..45a325a8b3 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -1,7 +1,7 @@ import pytest import socket -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( EthModuleTest, NetModuleTest, PersonalModuleTest, diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index bd5173841f..9c4da553fb 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -10,7 +10,7 @@ to_text, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, ) diff --git a/tests/integration/parity/common.py b/tests/integration/parity/common.py index d944d9b7c8..7f455efb4a 100644 --- a/tests/integration/parity/common.py +++ b/tests/integration/parity/common.py @@ -5,7 +5,7 @@ flaky, ) -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( EthModuleTest, ParityModuleTest as TraceModuleTest, PersonalModuleTest, diff --git a/tests/integration/parity/test_parity_http.py b/tests/integration/parity/test_parity_http.py index ceb5e1c5b4..e5b02a730e 100644 --- a/tests/integration/parity/test_parity_http.py +++ b/tests/integration/parity/test_parity_http.py @@ -5,7 +5,7 @@ wait_for_http, ) from web3 import Web3 -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( NetModuleTest, VersionModuleTest, ) diff --git a/tests/integration/parity/test_parity_ipc.py b/tests/integration/parity/test_parity_ipc.py index a9d821348a..48dc537875 100644 --- a/tests/integration/parity/test_parity_ipc.py +++ b/tests/integration/parity/test_parity_ipc.py @@ -6,7 +6,7 @@ wait_for_socket, ) from web3 import Web3 -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( NetModuleTest, VersionModuleTest, ) diff --git a/tests/integration/parity/test_parity_ws.py b/tests/integration/parity/test_parity_ws.py index 3e8bafa7c5..138d5b4659 100644 --- a/tests/integration/parity/test_parity_ws.py +++ b/tests/integration/parity/test_parity_ws.py @@ -8,7 +8,7 @@ wait_for_ws, ) from web3 import Web3 -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( NetModuleTest, VersionModuleTest, ) diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index 0fd81ff6de..c86545ee7d 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -10,19 +10,19 @@ ) from web3 import Web3 -from web3.providers.eth_tester import ( - EthereumTesterProvider, -) -from web3.utils.module_testing import ( +from web3._utils.module_testing import ( EthModuleTest, NetModuleTest, PersonalModuleTest, VersionModuleTest, Web3ModuleTest, ) -from web3.utils.module_testing.emitter_contract import ( +from web3._utils.module_testing.emitter_contract import ( EMITTER_ENUM, ) +from web3.providers.eth_tester import ( + EthereumTesterProvider, +) pytestmark = pytest.mark.filterwarnings("ignore:implicit cast from 'char *'") diff --git a/web3/utils/compat/compat_py2.py b/web3/_utils/__init__.py similarity index 100% rename from web3/utils/compat/compat_py2.py rename to web3/_utils/__init__.py diff --git a/web3/utils/abi.py b/web3/_utils/abi.py similarity index 99% rename from web3/utils/abi.py rename to web3/_utils/abi.py index d652c4491e..bb04f390e6 100644 --- a/web3/utils/abi.py +++ b/web3/_utils/abi.py @@ -15,20 +15,20 @@ to_tuple, ) -from web3.exceptions import ( - FallbackNotFound, -) -from web3.utils.ens import ( +from web3._utils.ens import ( is_ens_name, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( recursive_map, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( curry, partial, pipe, ) +from web3.exceptions import ( + FallbackNotFound, +) def filter_by_type(_type, contract_abi): diff --git a/web3/utils/blocks.py b/web3/_utils/blocks.py similarity index 100% rename from web3/utils/blocks.py rename to web3/_utils/blocks.py diff --git a/web3/utils/caching.py b/web3/_utils/caching.py similarity index 100% rename from web3/utils/caching.py rename to web3/_utils/caching.py diff --git a/web3/utils/compat/compat_py3.py b/web3/_utils/compat/compat_py2.py similarity index 100% rename from web3/utils/compat/compat_py3.py rename to web3/_utils/compat/compat_py2.py diff --git a/web3/_utils/compat/compat_py3.py b/web3/_utils/compat/compat_py3.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web3/utils/contracts.py b/web3/_utils/contracts.py similarity index 97% rename from web3/utils/contracts.py rename to web3/_utils/contracts.py index 3de3693a13..7dc607afe2 100644 --- a/web3/utils/contracts.py +++ b/web3/_utils/contracts.py @@ -16,10 +16,7 @@ HexBytes, ) -from web3.exceptions import ( - ValidationError, -) -from web3.utils.abi import ( +from web3._utils.abi import ( abi_to_signature, check_if_arguments_can_be_encoded, filter_by_argument_count, @@ -32,22 +29,25 @@ map_abi_data, merge_args_and_kwargs, ) -from web3.utils.encoding import ( +from web3._utils.encoding import ( to_hex, ) -from web3.utils.function_identifiers import ( +from web3._utils.function_identifiers import ( FallbackFn, ) -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( abi_address_to_hex, abi_bytes_to_bytes, abi_ens_resolver, abi_string_to_text, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( pipe, valmap, ) +from web3.exceptions import ( + ValidationError, +) def find_matching_event_abi(abi, event_name=None, argument_names=None): diff --git a/web3/utils/datatypes.py b/web3/_utils/datatypes.py similarity index 88% rename from web3/utils/datatypes.py rename to web3/_utils/datatypes.py index 7f5ce5ba53..2cc95c49de 100644 --- a/web3/utils/datatypes.py +++ b/web3/_utils/datatypes.py @@ -1,5 +1,5 @@ -import web3.utils.formatters -from web3.utils.toolz import ( +import web3._utils.formatters +from web3._utils.toolz import ( concat, curry, ) @@ -28,7 +28,7 @@ def __new__(mcs, name, bases, namespace, normalizers=None): verify_key_attr(concat(base.__dict__.keys() for base in all_bases)) if normalizers: - processed_namespace = web3.utils.formatters.apply_formatters_to_dict( + processed_namespace = web3._utils.formatters.apply_formatters_to_dict( normalizers, namespace) else: diff --git a/web3/utils/decorators.py b/web3/_utils/decorators.py similarity index 100% rename from web3/utils/decorators.py rename to web3/_utils/decorators.py diff --git a/web3/utils/empty.py b/web3/_utils/empty.py similarity index 100% rename from web3/utils/empty.py rename to web3/_utils/empty.py diff --git a/web3/utils/encoding.py b/web3/_utils/encoding.py similarity index 98% rename from web3/utils/encoding.py rename to web3/_utils/encoding.py index 74375fef8d..37c64e2894 100644 --- a/web3/utils/encoding.py +++ b/web3/_utils/encoding.py @@ -17,7 +17,7 @@ to_hex, ) -from web3.utils.abi import ( +from web3._utils.abi import ( is_address_type, is_array_type, is_bool_type, @@ -28,10 +28,10 @@ size_of_type, sub_type_of_array_type, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( curry, ) -from web3.utils.validation import ( +from web3._utils.validation import ( assert_one_val, validate_abi_type, validate_abi_value, diff --git a/web3/utils/ens.py b/web3/_utils/ens.py similarity index 100% rename from web3/utils/ens.py rename to web3/_utils/ens.py diff --git a/web3/utils/events.py b/web3/_utils/events.py similarity index 98% rename from web3/utils/events.py rename to web3/_utils/events.py index c13ed5ab21..bbf9208378 100644 --- a/web3/utils/events.py +++ b/web3/_utils/events.py @@ -12,26 +12,23 @@ to_tuple, ) -from web3.datastructures import ( - AttributeDict, -) -from web3.exceptions import ( - MismatchedABI, -) -from web3.utils.abi import ( - process_type, -) -from web3.utils.encoding import ( +from web3._utils.encoding import ( hexstr_if_str, to_bytes, ) -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( BASE_RETURN_NORMALIZERS, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, curry, ) +from web3.datastructures import ( + AttributeDict, +) +from web3.exceptions import ( + MismatchedABI, +) from .abi import ( exclude_indexed_event_inputs, @@ -39,6 +36,7 @@ get_indexed_event_inputs, map_abi_data, normalize_event_input_types, + process_type, ) diff --git a/web3/utils/filters.py b/web3/_utils/filters.py similarity index 98% rename from web3/utils/filters.py rename to web3/_utils/filters.py index ba85d2484c..b7015d148b 100644 --- a/web3/utils/filters.py +++ b/web3/_utils/filters.py @@ -5,10 +5,10 @@ is_string, ) -from web3.utils.threads import ( +from web3._utils.threads import ( TimerClass, ) -from web3.utils.validation import ( +from web3._utils.validation import ( validate_address, ) diff --git a/web3/utils/formatters.py b/web3/_utils/formatters.py similarity index 98% rename from web3/utils/formatters.py rename to web3/_utils/formatters.py index 85a5af639d..8e33b38388 100644 --- a/web3/utils/formatters.py +++ b/web3/_utils/formatters.py @@ -11,10 +11,10 @@ to_list, ) -from web3.utils.decorators import ( +from web3._utils.decorators import ( reject_recursive_repeats, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, curry, dissoc, diff --git a/web3/utils/function_identifiers.py b/web3/_utils/function_identifiers.py similarity index 100% rename from web3/utils/function_identifiers.py rename to web3/_utils/function_identifiers.py diff --git a/web3/utils/http.py b/web3/_utils/http.py similarity index 100% rename from web3/utils/http.py rename to web3/_utils/http.py diff --git a/web3/utils/hypothesis.py b/web3/_utils/hypothesis.py similarity index 100% rename from web3/utils/hypothesis.py rename to web3/_utils/hypothesis.py diff --git a/web3/utils/math.py b/web3/_utils/math.py similarity index 100% rename from web3/utils/math.py rename to web3/_utils/math.py diff --git a/web3/utils/module_testing/__init__.py b/web3/_utils/module_testing/__init__.py similarity index 100% rename from web3/utils/module_testing/__init__.py rename to web3/_utils/module_testing/__init__.py diff --git a/web3/utils/module_testing/emitter_contract.py b/web3/_utils/module_testing/emitter_contract.py similarity index 100% rename from web3/utils/module_testing/emitter_contract.py rename to web3/_utils/module_testing/emitter_contract.py diff --git a/web3/utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py similarity index 100% rename from web3/utils/module_testing/eth_module.py rename to web3/_utils/module_testing/eth_module.py diff --git a/web3/utils/module_testing/math_contract.py b/web3/_utils/module_testing/math_contract.py similarity index 100% rename from web3/utils/module_testing/math_contract.py rename to web3/_utils/module_testing/math_contract.py diff --git a/web3/utils/module_testing/net_module.py b/web3/_utils/module_testing/net_module.py similarity index 100% rename from web3/utils/module_testing/net_module.py rename to web3/_utils/module_testing/net_module.py diff --git a/web3/utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py similarity index 99% rename from web3/utils/module_testing/parity_module.py rename to web3/_utils/module_testing/parity_module.py index c1383db39f..a6b25f45f9 100644 --- a/web3/utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -4,7 +4,7 @@ add_0x_prefix, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( hex_to_integer, ) diff --git a/web3/utils/module_testing/personal_module.py b/web3/_utils/module_testing/personal_module.py similarity index 100% rename from web3/utils/module_testing/personal_module.py rename to web3/_utils/module_testing/personal_module.py diff --git a/web3/utils/module_testing/version_module.py b/web3/_utils/module_testing/version_module.py similarity index 100% rename from web3/utils/module_testing/version_module.py rename to web3/_utils/module_testing/version_module.py diff --git a/web3/utils/module_testing/web3_module.py b/web3/_utils/module_testing/web3_module.py similarity index 99% rename from web3/utils/module_testing/web3_module.py rename to web3/_utils/module_testing/web3_module.py index 36d400297e..e978a6d742 100644 --- a/web3/utils/module_testing/web3_module.py +++ b/web3/_utils/module_testing/web3_module.py @@ -5,12 +5,12 @@ ) from web3 import Web3 +from web3._utils.ens import ( + ens_addresses, +) from web3.exceptions import ( InvalidAddress, ) -from web3.utils.ens import ( - ens_addresses, -) class Web3ModuleTest: diff --git a/web3/utils/normalizers.py b/web3/_utils/normalizers.py similarity index 96% rename from web3/utils/normalizers.py rename to web3/_utils/normalizers.py index 0372eba817..daf1e8bd78 100644 --- a/web3/utils/normalizers.py +++ b/web3/_utils/normalizers.py @@ -17,31 +17,31 @@ HexBytes, ) -from web3.exceptions import ( - InvalidAddress, -) -from web3.utils.abi import ( +from web3._utils.abi import ( process_type, ) -from web3.utils.encoding import ( +from web3._utils.encoding import ( hexstr_if_str, text_if_str, to_bytes, to_hex, to_text, ) -from web3.utils.ens import ( +from web3._utils.ens import ( StaticENS, is_ens_name, validate_name_has_address, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( curry, ) -from web3.utils.validation import ( +from web3._utils.validation import ( validate_abi, validate_address, ) +from web3.exceptions import ( + InvalidAddress, +) def implicitly_identity(to_wrap): diff --git a/web3/utils/request.py b/web3/_utils/request.py similarity index 95% rename from web3/utils/request.py rename to web3/_utils/request.py index 3e5484ae9f..c43157d6db 100644 --- a/web3/utils/request.py +++ b/web3/_utils/request.py @@ -1,7 +1,7 @@ import lru import requests -from web3.utils.caching import ( +from web3._utils.caching import ( generate_cache_key, ) diff --git a/web3/utils/rpc_abi.py b/web3/_utils/rpc_abi.py similarity index 96% rename from web3/utils/rpc_abi.py rename to web3/_utils/rpc_abi.py index 2392e8b3a9..602cb2bd04 100644 --- a/web3/utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -2,13 +2,13 @@ to_dict, ) -from web3.utils.abi import ( +from web3._utils.abi import ( map_abi_data, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_at_index, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( curry, ) diff --git a/web3/utils/six/__init__.py b/web3/_utils/six/__init__.py similarity index 100% rename from web3/utils/six/__init__.py rename to web3/_utils/six/__init__.py diff --git a/web3/utils/six/six.py b/web3/_utils/six/six.py similarity index 100% rename from web3/utils/six/six.py rename to web3/_utils/six/six.py diff --git a/web3/utils/threads.py b/web3/_utils/threads.py similarity index 100% rename from web3/utils/threads.py rename to web3/_utils/threads.py diff --git a/web3/utils/toolz/__init__.py b/web3/_utils/toolz/__init__.py similarity index 100% rename from web3/utils/toolz/__init__.py rename to web3/_utils/toolz/__init__.py diff --git a/web3/utils/toolz/curried.py b/web3/_utils/toolz/curried.py similarity index 100% rename from web3/utils/toolz/curried.py rename to web3/_utils/toolz/curried.py diff --git a/web3/utils/transactions.py b/web3/_utils/transactions.py similarity index 98% rename from web3/utils/transactions.py rename to web3/_utils/transactions.py index d2a2389dca..c48d1a2024 100644 --- a/web3/utils/transactions.py +++ b/web3/_utils/transactions.py @@ -1,9 +1,9 @@ import math -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, curry, merge, diff --git a/web3/utils/validation.py b/web3/_utils/validation.py similarity index 98% rename from web3/utils/validation.py rename to web3/_utils/validation.py index b9a2fda5ef..5284a1e9cd 100644 --- a/web3/utils/validation.py +++ b/web3/_utils/validation.py @@ -17,10 +17,7 @@ encode_hex, ) -from web3.exceptions import ( - InvalidAddress, -) -from web3.utils.abi import ( +from web3._utils.abi import ( abi_to_signature, filter_by_type, is_address_type, @@ -34,15 +31,18 @@ length_of_array_type, sub_type_of_array_type, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_to_array, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, groupby, valfilter, valmap, ) +from web3.exceptions import ( + InvalidAddress, +) def _prepare_selector_collision_msg(duplicates): diff --git a/web3/utils/windows.py b/web3/_utils/windows.py similarity index 99% rename from web3/utils/windows.py rename to web3/_utils/windows.py index 97d1838c0b..a0df47e7b7 100644 --- a/web3/utils/windows.py +++ b/web3/_utils/windows.py @@ -1,14 +1,12 @@ import sys +import pywintypes # noqa: E402 +import win32file # noqa: E402 if sys.platform != 'win32': raise ImportError("This module should not be imported on non `win32` platforms") -import win32file # noqa: E402 -import pywintypes # noqa: E402 - - class NamedPipe: def __init__(self, ipc_path): try: diff --git a/web3/contract.py b/web3/contract.py index e738ca4641..eb5e68092c 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -22,15 +22,7 @@ HexBytes, ) -from web3.exceptions import ( - BadFunctionCallOutput, - BlockNumberOutofRange, - FallbackNotFound, - MismatchedABI, - NoABIEventsFound, - NoABIFunctionsFound, -) -from web3.utils.abi import ( +from web3._utils.abi import ( abi_to_signature, check_if_arguments_can_be_encoded, fallback_func_abi_exists, @@ -40,52 +32,60 @@ map_abi_data, merge_args_and_kwargs, ) -from web3.utils.blocks import ( +from web3._utils.blocks import ( is_hex_encoded_block_hash, ) -from web3.utils.contracts import ( +from web3._utils.contracts import ( encode_abi, find_matching_event_abi, find_matching_fn_abi, get_function_info, prepare_transaction, ) -from web3.utils.datatypes import ( +from web3._utils.datatypes import ( PropertyCheckingFactory, ) -from web3.utils.decorators import ( +from web3._utils.decorators import ( combomethod, deprecated_for, ) -from web3.utils.empty import ( +from web3._utils.empty import ( empty, ) -from web3.utils.encoding import ( +from web3._utils.encoding import ( to_4byte_hex, to_hex, ) -from web3.utils.events import ( +from web3._utils.events import ( get_event_data, ) -from web3.utils.filters import ( +from web3._utils.filters import ( construct_event_filter_params, ) -from web3.utils.function_identifiers import ( +from web3._utils.function_identifiers import ( FallbackFn, ) -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( BASE_RETURN_NORMALIZERS, normalize_abi, normalize_address, normalize_bytecode, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, partial, ) -from web3.utils.transactions import ( +from web3._utils.transactions import ( fill_transaction_defaults, ) +from web3.exceptions import ( + BadFunctionCallOutput, + BlockNumberOutofRange, + FallbackNotFound, + MismatchedABI, + NoABIEventsFound, + NoABIFunctionsFound, +) DEPRECATED_SIGNATURE_MESSAGE = ( "The constructor signature for the `Contract` object has changed. " diff --git a/web3/datastructures.py b/web3/datastructures.py index 7b5510b1a1..116eded686 100644 --- a/web3/datastructures.py +++ b/web3/datastructures.py @@ -10,7 +10,7 @@ is_integer, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( recursive_map, ) diff --git a/web3/eth.py b/web3/eth.py index 195fdd056b..bd945c23cc 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -10,37 +10,28 @@ HexBytes, ) -from web3.contract import ( - Contract, -) -from web3.iban import ( - Iban, -) -from web3.module import ( - Module, -) -from web3.utils.blocks import ( +from web3._utils.blocks import ( select_method_for_block_identifier, ) -from web3.utils.decorators import ( +from web3._utils.decorators import ( deprecated_for, ) -from web3.utils.empty import ( +from web3._utils.empty import ( empty, ) -from web3.utils.encoding import ( +from web3._utils.encoding import ( to_hex, ) -from web3.utils.filters import ( +from web3._utils.filters import ( BlockFilter, LogFilter, TransactionFilter, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, merge, ) -from web3.utils.transactions import ( +from web3._utils.transactions import ( assert_valid_transaction_params, extract_valid_transaction_params, get_buffered_gas_estimate, @@ -48,6 +39,15 @@ replace_transaction, wait_for_transaction_receipt, ) +from web3.contract import ( + Contract, +) +from web3.iban import ( + Iban, +) +from web3.module import ( + Module, +) class Eth(Module): diff --git a/web3/gas_strategies/time_based.py b/web3/gas_strategies/time_based.py index 6f4df07bb4..dee908df5c 100644 --- a/web3/gas_strategies/time_based.py +++ b/web3/gas_strategies/time_based.py @@ -6,18 +6,18 @@ to_tuple, ) -from web3.exceptions import ( - InsufficientData, - ValidationError, -) -from web3.utils.math import ( +from web3._utils.math import ( percentile, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( curry, groupby, sliding_window, ) +from web3.exceptions import ( + InsufficientData, + ValidationError, +) MinerData = collections.namedtuple( 'MinerData', diff --git a/web3/iban.py b/web3/iban.py index 1b0cabe496..aa1ad25676 100644 --- a/web3/iban.py +++ b/web3/iban.py @@ -6,7 +6,7 @@ to_checksum_address, ) -from web3.utils.validation import ( +from web3._utils.validation import ( validate_address, ) diff --git a/web3/main.py b/web3/main.py index 89087e1fd3..f27d78a2d2 100644 --- a/web3/main.py +++ b/web3/main.py @@ -1,6 +1,6 @@ from eth_utils import ( - apply_to_return_value, add_0x_prefix, + apply_to_return_value, from_wei, is_address, is_checksum_address, @@ -9,20 +9,55 @@ to_checksum_address, to_wei, ) +from hexbytes import ( + HexBytes, +) from ens import ENS - -from web3.admin import Admin -from web3.eth import Eth -from web3.iban import Iban -from web3.miner import Miner -from web3.net import Net -from web3.parity import Parity -from web3.personal import Personal -from web3.testing import Testing -from web3.txpool import TxPool -from web3.version import Version - +from web3._utils.abi import ( + map_abi_data, +) +from web3._utils.decorators import ( + combomethod, + deprecated_for, +) +from web3._utils.empty import ( + empty, +) +from web3._utils.encoding import ( + hex_encode_abi_type, + to_bytes, + to_hex, + to_int, + to_text, +) +from web3._utils.normalizers import ( + abi_ens_resolver, +) +from web3.admin import ( + Admin, +) +from web3.eth import ( + Eth, +) +from web3.iban import ( + Iban, +) +from web3.manager import ( + RequestManager, +) +from web3.miner import ( + Miner, +) +from web3.net import ( + Net, +) +from web3.parity import ( + Parity, +) +from web3.personal import ( + Personal, +) from web3.providers.eth_tester import ( EthereumTesterProvider, ) @@ -36,33 +71,16 @@ TestRPCProvider, ) from web3.providers.websocket import ( - WebsocketProvider -) - -from web3.manager import ( - RequestManager, -) - -from web3.utils.abi import ( - map_abi_data, -) -from hexbytes import ( - HexBytes, + WebsocketProvider, ) -from web3.utils.decorators import ( - combomethod, - deprecated_for, +from web3.testing import ( + Testing, ) -from web3.utils.empty import empty -from web3.utils.encoding import ( - hex_encode_abi_type, - to_bytes, - to_int, - to_hex, - to_text, +from web3.txpool import ( + TxPool, ) -from web3.utils.normalizers import ( - abi_ens_resolver, +from web3.version import ( + Version, ) diff --git a/web3/manager.py b/web3/manager.py index 737a2c6807..c8e169fa3f 100644 --- a/web3/manager.py +++ b/web3/manager.py @@ -5,6 +5,12 @@ is_list_like, ) +from web3._utils.empty import ( + empty, +) +from web3._utils.threads import ( + spawn, +) from web3.datastructures import ( NamedElementOnion, ) @@ -25,12 +31,6 @@ from web3.providers import ( AutoProvider, ) -from web3.utils.empty import ( - empty, -) -from web3.utils.threads import ( - spawn, -) class RequestManager: diff --git a/web3/middleware/abi.py b/web3/middleware/abi.py index aba197d566..cfcae4e8cd 100644 --- a/web3/middleware/abi.py +++ b/web3/middleware/abi.py @@ -1,10 +1,10 @@ -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( abi_address_to_hex, abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, ) -from web3.utils.rpc_abi import ( +from web3._utils.rpc_abi import ( RPC_ABIS, abi_request_formatters, ) diff --git a/web3/middleware/attrdict.py b/web3/middleware/attrdict.py index 7aef9bb39d..4043ca3d16 100644 --- a/web3/middleware/attrdict.py +++ b/web3/middleware/attrdict.py @@ -2,12 +2,12 @@ is_dict, ) +from web3._utils.toolz import ( + assoc, +) from web3.datastructures import ( AttributeDict, ) -from web3.utils.toolz import ( - assoc, -) def attrdict_middleware(make_request, web3): diff --git a/web3/middleware/cache.py b/web3/middleware/cache.py index 56eeef0592..fa56a98b3b 100644 --- a/web3/middleware/cache.py +++ b/web3/middleware/cache.py @@ -4,7 +4,7 @@ import lru -from web3.utils.caching import ( +from web3._utils.caching import ( generate_cache_key, ) diff --git a/web3/middleware/exception_handling.py b/web3/middleware/exception_handling.py index 1715d575ff..1b9d14f5dc 100644 --- a/web3/middleware/exception_handling.py +++ b/web3/middleware/exception_handling.py @@ -1,4 +1,4 @@ -from web3.utils.toolz import ( +from web3._utils.toolz import ( excepts, ) diff --git a/web3/middleware/formatting.py b/web3/middleware/formatting.py index dc5f510d26..dd75ad07c4 100644 --- a/web3/middleware/formatting.py +++ b/web3/middleware/formatting.py @@ -1,4 +1,4 @@ -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, curry, merge, diff --git a/web3/middleware/gas_price_strategy.py b/web3/middleware/gas_price_strategy.py index f4334de64f..4e493b8540 100644 --- a/web3/middleware/gas_price_strategy.py +++ b/web3/middleware/gas_price_strategy.py @@ -1,4 +1,4 @@ -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, ) diff --git a/web3/middleware/geth_poa.py b/web3/middleware/geth_poa.py index bc81336961..aa9147e8d8 100644 --- a/web3/middleware/geth_poa.py +++ b/web3/middleware/geth_poa.py @@ -6,12 +6,12 @@ HexBytes, ) +from web3._utils.toolz import ( + compose, +) from web3.middleware.formatting import ( construct_formatting_middleware, ) -from web3.utils.toolz import ( - compose, -) remap_geth_poa_fields = apply_key_map({ 'extraData': 'proofOfAuthorityData', diff --git a/web3/middleware/names.py b/web3/middleware/names.py index d52a88ef70..65a62dc121 100644 --- a/web3/middleware/names.py +++ b/web3/middleware/names.py @@ -1,7 +1,7 @@ -from web3.utils.normalizers import ( +from web3._utils.normalizers import ( abi_ens_resolver, ) -from web3.utils.rpc_abi import ( +from web3._utils.rpc_abi import ( RPC_ABIS, abi_request_formatters, ) diff --git a/web3/middleware/normalize_errors.py b/web3/middleware/normalize_errors.py index 309f2fd749..8937375858 100644 --- a/web3/middleware/normalize_errors.py +++ b/web3/middleware/normalize_errors.py @@ -1,4 +1,4 @@ -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, dissoc, ) diff --git a/web3/middleware/normalize_request_parameters.py b/web3/middleware/normalize_request_parameters.py index bc6ffa3ed0..21a576830d 100644 --- a/web3/middleware/normalize_request_parameters.py +++ b/web3/middleware/normalize_request_parameters.py @@ -2,7 +2,7 @@ is_string, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_at_index, apply_formatter_if, apply_formatters_to_dict, diff --git a/web3/middleware/pythonic.py b/web3/middleware/pythonic.py index 8ac00eb2c7..1ba6d3fc18 100644 --- a/web3/middleware/pythonic.py +++ b/web3/middleware/pythonic.py @@ -16,11 +16,11 @@ HexBytes, ) -from web3.utils.encoding import ( +from web3._utils.encoding import ( hexstr_if_str, to_hex, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_at_index, apply_formatter_if, apply_formatter_to_array, @@ -32,13 +32,13 @@ is_array_of_strings, remove_key_if, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( complement, compose, curry, partial, ) -from web3.utils.toolz.curried import ( +from web3._utils.toolz.curried import ( keymap, valmap, ) diff --git a/web3/middleware/signing.py b/web3/middleware/signing.py index bbb433e2b9..4c8534c55a 100644 --- a/web3/middleware/signing.py +++ b/web3/middleware/signing.py @@ -16,13 +16,13 @@ to_dict, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_if, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, ) -from web3.utils.transactions import ( +from web3._utils.transactions import ( fill_nonce, fill_transaction_defaults, ) diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 26a48e649d..b13938da60 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -8,18 +8,18 @@ HexBytes, ) +from web3._utils.toolz import ( + complement, + compose, + curry, + dissoc, +) from web3.exceptions import ( ValidationError, ) from web3.middleware.formatting import ( construct_web3_formatting_middleware, ) -from web3.utils.toolz import ( - complement, - compose, - curry, - dissoc, -) MAX_EXTRADATA_LENGTH = 32 diff --git a/web3/parity.py b/web3/parity.py index f4a5311ed2..3b37908d1d 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -2,12 +2,12 @@ is_checksum_address, ) +from web3._utils.toolz import ( + assoc, +) from web3.module import ( Module, ) -from web3.utils.toolz import ( - assoc, -) class Parity(Module): diff --git a/web3/providers/base.py b/web3/providers/base.py index 9bf820537a..3a010f8667 100644 --- a/web3/providers/base.py +++ b/web3/providers/base.py @@ -5,12 +5,12 @@ to_text, ) +from web3._utils.encoding import ( + FriendlyJsonSerde, +) from web3.middleware import ( combine_middlewares, ) -from web3.utils.encoding import ( - FriendlyJsonSerde, -) class BaseProvider: diff --git a/web3/providers/eth_tester/defaults.py b/web3/providers/eth_tester/defaults.py index fd346156aa..f260f922a9 100644 --- a/web3/providers/eth_tester/defaults.py +++ b/web3/providers/eth_tester/defaults.py @@ -15,10 +15,10 @@ keccak, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_if, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( compose, curry, excepts, diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py index dec47c71a6..b5e4e0d180 100644 --- a/web3/providers/eth_tester/middleware.py +++ b/web3/providers/eth_tester/middleware.py @@ -6,11 +6,7 @@ is_string, ) -from web3.middleware import ( - construct_fixture_middleware, - construct_formatting_middleware, -) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_if, apply_formatter_to_array, apply_formatters_to_args, @@ -22,7 +18,7 @@ remove_key_if, static_return, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( assoc, complement, compose, @@ -31,6 +27,10 @@ partial, pipe, ) +from web3.middleware import ( + construct_fixture_middleware, + construct_formatting_middleware, +) def is_named_block(value): diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py index fac80f7be5..a151d1e3a6 100644 --- a/web3/providers/ipc.py +++ b/web3/providers/ipc.py @@ -5,7 +5,7 @@ import sys import threading -from web3.utils.threads import ( +from web3._utils.threads import ( Timeout, ) @@ -22,7 +22,7 @@ def get_ipc_socket(ipc_path, timeout=0.1): if sys.platform == 'win32': # On Windows named pipe is used. Simulate socket with it. - from web3.utils.windows import NamedPipe + from web3._utils.windows import NamedPipe return NamedPipe(ipc_path) else: diff --git a/web3/providers/rpc.py b/web3/providers/rpc.py index bd07acce39..b939f2a9a0 100644 --- a/web3/providers/rpc.py +++ b/web3/providers/rpc.py @@ -5,18 +5,18 @@ to_dict, ) +from web3._utils.http import ( + construct_user_agent, +) +from web3._utils.request import ( + make_post_request, +) from web3.datastructures import ( NamedElementOnion, ) from web3.middleware import ( http_retry_request_middleware, ) -from web3.utils.http import ( - construct_user_agent, -) -from web3.utils.request import ( - make_post_request, -) from .base import ( JSONBaseProvider, diff --git a/web3/providers/tester.py b/web3/providers/tester.py index 1fd7594939..e6d56546c2 100644 --- a/web3/providers/tester.py +++ b/web3/providers/tester.py @@ -9,14 +9,10 @@ to_text, ) -from web3.middleware import ( - construct_exception_handler_middleware, - construct_formatting_middleware, -) -from web3.utils.decorators import ( +from web3._utils.decorators import ( deprecated_for, ) -from web3.utils.formatters import ( +from web3._utils.formatters import ( apply_formatter_at_index, apply_formatter_if, apply_formatters_to_dict, @@ -24,14 +20,18 @@ static_result, static_return, ) -from web3.utils.threads import ( +from web3._utils.threads import ( spawn, ) -from web3.utils.toolz import ( +from web3._utils.toolz import ( complement, compose, valmap, ) +from web3.middleware import ( + construct_exception_handler_middleware, + construct_formatting_middleware, +) from .base import ( BaseProvider, diff --git a/web3/shh.py b/web3/shh.py index 52875ab3a9..2e1fd23e30 100644 --- a/web3/shh.py +++ b/web3/shh.py @@ -1,9 +1,9 @@ +from web3._utils.filters import ( + ShhFilter, +) from web3.module import ( Module, ) -from web3.utils.filters import ( - ShhFilter, -) class Shh(Module): diff --git a/web3/utils/__init__.py b/web3/utils/__init__.py index e69de29bb2..bee0cbea8d 100644 --- a/web3/utils/__init__.py +++ b/web3/utils/__init__.py @@ -0,0 +1,28 @@ +from web3._utils import ( # noqa: F401 + abi, + blocks, + caching, + compat, + contracts, + datatypes, + decorators, + empty, + encoding, + ens, + events, + filters, + formatters, + function_identifiers, + http, + hypothesis, + math, + module_testing, + normalizers, + request, + rpc_abi, + six, + threads, + toolz, + transactions, + validation, +)