diff --git a/tests/conftest.py b/tests/conftest.py index 5f8d7ecf6f..a3fcb4bad0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,8 +3,7 @@ from eth_utils import ( to_bytes, ) - -from web3._utils.toolz import ( +from eth_utils.toolz import ( identity, ) diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index a6e1dcbce2..acc4b29e15 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -1,13 +1,12 @@ import pytest -from hexbytes import ( - HexBytes, -) - -from web3._utils.toolz import ( +from eth_utils.toolz import ( compose, curry, ) +from hexbytes import ( + HexBytes, +) AMBIGUOUS_CONTRACT_ABI = [ { diff --git a/tests/core/contracts/test_contract_buildTransaction.py b/tests/core/contracts/test_contract_buildTransaction.py index 7034193d06..4e033f8e3c 100644 --- a/tests/core/contracts/test_contract_buildTransaction.py +++ b/tests/core/contracts/test_contract_buildTransaction.py @@ -2,9 +2,10 @@ import pytest -from web3._utils.toolz import ( +from eth_utils.toolz import ( dissoc, ) + from web3.exceptions import ( ValidationError, ) diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 8357cc22b7..af9269513c 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -9,6 +9,9 @@ import pytest import eth_abi +from eth_utils.toolz import ( + identity, +) from hexbytes import ( HexBytes, ) @@ -16,9 +19,6 @@ from web3._utils.ens import ( contract_ens_addresses, ) -from web3._utils.toolz import ( - identity, -) from web3.exceptions import ( BadFunctionCallOutput, BlockNumberOutofRange, diff --git a/tests/core/contracts/test_contract_caller_interface.py b/tests/core/contracts/test_contract_caller_interface.py index 1a66226a7c..b73d4150e2 100644 --- a/tests/core/contracts/test_contract_caller_interface.py +++ b/tests/core/contracts/test_contract_caller_interface.py @@ -1,8 +1,9 @@ import pytest -from web3._utils.toolz import ( +from eth_utils.toolz import ( identity, ) + from web3.exceptions import ( MismatchedABI, NoABIFound, 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 3a0c188032..8bcebb37f4 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,11 +1,12 @@ import pytest +from eth_utils.toolz import ( + partial, +) + from web3._utils.blocks import ( select_method_for_block_identifier, ) -from web3._utils.toolz import ( - partial, -) selector_fn = partial( select_method_for_block_identifier, diff --git a/tests/core/eth-module/test_accounts.py b/tests/core/eth-module/test_accounts.py index 8654b8bb31..2f5b70d4c5 100644 --- a/tests/core/eth-module/test_accounts.py +++ b/tests/core/eth-module/test_accounts.py @@ -8,6 +8,9 @@ from eth_utils import ( is_checksum_address, ) +from eth_utils.toolz import ( + dissoc, +) from hexbytes import ( HexBytes, ) @@ -20,9 +23,6 @@ to_bytes, to_hex, ) -from web3._utils.toolz import ( - dissoc, -) from web3.providers.eth_tester import ( EthereumTesterProvider, ) diff --git a/tests/core/middleware/test_transaction_signing.py b/tests/core/middleware/test_transaction_signing.py index 8ef18dc4a7..3b07139558 100644 --- a/tests/core/middleware/test_transaction_signing.py +++ b/tests/core/middleware/test_transaction_signing.py @@ -14,16 +14,16 @@ to_bytes, to_hex, ) +from eth_utils.toolz import ( + identity, + merge, + valfilter, +) from hexbytes import ( HexBytes, ) from web3 import Web3 -from web3._utils.toolz import ( - identity, - merge, - valfilter, -) from web3.exceptions import ( InvalidAddress, ) diff --git a/tests/generate_go_ethereum_fixture.py b/tests/generate_go_ethereum_fixture.py index 3d1e7b35a7..8d307f8038 100644 --- a/tests/generate_go_ethereum_fixture.py +++ b/tests/generate_go_ethereum_fixture.py @@ -21,6 +21,10 @@ to_text, to_wei, ) +from eth_utils.toolz import ( + merge, + valmap, +) from tests.utils import ( get_open_port, @@ -35,10 +39,6 @@ MATH_ABI, MATH_BYTECODE, ) -from web3._utils.toolz import ( - merge, - valmap, -) COINBASE = '0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd' COINBASE_PK = '0x58d23b55bc9cdce1f18c2500f40ff4ab7245df9a89505e9b1fa4851f623d241d' diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index f9b0e4bf44..9f593ad446 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -9,6 +9,9 @@ is_dict, is_same_address, ) +from eth_utils.toolz import ( + merge, +) import common from tests.utils import ( @@ -24,9 +27,6 @@ MATH_ABI, MATH_BYTECODE, ) -from web3._utils.toolz import ( - merge, -) # this script is used for generating the parity fixture # to generate geth fixtures use tests/generate_go_ethereum_fixture.py diff --git a/tests/integration/generate_fixtures/parity.py b/tests/integration/generate_fixtures/parity.py index c5f2f795e8..bf81642c6a 100644 --- a/tests/integration/generate_fixtures/parity.py +++ b/tests/integration/generate_fixtures/parity.py @@ -9,6 +9,9 @@ from eth_utils import ( to_text, ) +from eth_utils.toolz import ( + merge, +) import common import go_ethereum @@ -16,9 +19,6 @@ get_open_port, ) from web3 import Web3 -from web3._utils.toolz import ( - merge, -) CHAIN_CONFIG = { "name": "CrossClient", diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index ab8f27d614..851fcd5dca 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -43,6 +43,11 @@ from eth_utils.abi import ( collapse_if_tuple, ) +from eth_utils.toolz import ( + curry, + partial, + pipe, +) from web3._utils.ens import ( is_ens_name, @@ -50,11 +55,6 @@ from web3._utils.formatters import ( recursive_map, ) -from web3._utils.toolz import ( - curry, - partial, - pipe, -) from web3.exceptions import ( FallbackNotFound, ) diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index 9e8efd1626..90ecc17e93 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -9,6 +9,10 @@ function_abi_to_4byte_selector, is_text, ) +from eth_utils.toolz import ( + pipe, + valmap, +) from hexbytes import ( HexBytes, ) @@ -39,10 +43,6 @@ abi_ens_resolver, abi_string_to_text, ) -from web3._utils.toolz import ( - pipe, - valmap, -) from web3.exceptions import ( ValidationError, ) diff --git a/web3/_utils/datatypes.py b/web3/_utils/datatypes.py index 8cec1f04ab..da0c33a194 100644 --- a/web3/_utils/datatypes.py +++ b/web3/_utils/datatypes.py @@ -1,8 +1,9 @@ -import web3._utils.formatters -from web3._utils.toolz import ( +from eth_utils.toolz import ( concat, ) +import web3._utils.formatters + def verify_attr(class_name, key, namespace): if key not in namespace: diff --git a/web3/_utils/encoding.py b/web3/_utils/encoding.py index 3e066e2e0b..b727278973 100644 --- a/web3/_utils/encoding.py +++ b/web3/_utils/encoding.py @@ -19,6 +19,9 @@ remove_0x_prefix, to_hex, ) +from eth_utils.toolz import ( + curry, +) from hexbytes import ( HexBytes, ) @@ -34,9 +37,6 @@ size_of_type, sub_type_of_array_type, ) -from web3._utils.toolz import ( - curry, -) from web3._utils.validation import ( assert_one_val, validate_abi_type, diff --git a/web3/_utils/events.py b/web3/_utils/events.py index 45affc85a4..81defc25e0 100644 --- a/web3/_utils/events.py +++ b/web3/_utils/events.py @@ -22,6 +22,13 @@ to_hex, to_tuple, ) +from eth_utils.toolz import ( + complement, + compose, + cons, + curry, + valfilter, +) import web3 from web3._utils.encoding import ( @@ -35,13 +42,6 @@ from web3._utils.normalizers import ( BASE_RETURN_NORMALIZERS, ) -from web3._utils.toolz import ( - complement, - compose, - cons, - curry, - valfilter, -) from web3.datastructures import ( AttributeDict, ) diff --git a/web3/_utils/filters.py b/web3/_utils/filters.py index e41dc1cc7f..a6204012dc 100644 --- a/web3/_utils/filters.py +++ b/web3/_utils/filters.py @@ -10,6 +10,10 @@ is_string, is_text, ) +from eth_utils.toolz import ( + complement, + curry, +) from hexbytes import ( HexBytes, ) @@ -20,10 +24,6 @@ from web3._utils.threads import ( TimerClass, ) -from web3._utils.toolz import ( - complement, - curry, -) from web3._utils.validation import ( validate_address, ) diff --git a/web3/_utils/formatters.py b/web3/_utils/formatters.py index f2d8aed6d5..ee081eee80 100644 --- a/web3/_utils/formatters.py +++ b/web3/_utils/formatters.py @@ -10,16 +10,16 @@ to_dict, to_list, ) - -from web3._utils.decorators import ( - reject_recursive_repeats, -) -from web3._utils.toolz import ( +from eth_utils.toolz import ( compose, curry, dissoc, ) +from web3._utils.decorators import ( + reject_recursive_repeats, +) + def hex_to_integer(value): return int(value, 16) diff --git a/web3/_utils/normalizers.py b/web3/_utils/normalizers.py index ab873ca95b..9d2088637c 100644 --- a/web3/_utils/normalizers.py +++ b/web3/_utils/normalizers.py @@ -20,6 +20,9 @@ from eth_utils.address import ( is_binary_address, ) +from eth_utils.toolz import ( + curry, +) from hexbytes import ( HexBytes, ) @@ -36,9 +39,6 @@ is_ens_name, validate_name_has_address, ) -from web3._utils.toolz import ( - curry, -) from web3._utils.validation import ( validate_abi, validate_address, diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index 5ca058083c..0a32bff477 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -1,6 +1,9 @@ from eth_utils import ( to_dict, ) +from eth_utils.toolz import ( + curry, +) from web3._utils.abi import ( map_abi_data, @@ -8,9 +11,6 @@ from web3._utils.formatters import ( apply_formatter_at_index, ) -from web3._utils.toolz import ( - curry, -) TRANSACTION_PARAMS_ABIS = { 'data': 'bytes', diff --git a/web3/_utils/toolz/__init__.py b/web3/_utils/toolz/__init__.py deleted file mode 100644 index f76ed43e4e..0000000000 --- a/web3/_utils/toolz/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -try: - from cytoolz import ( - assoc, - complement, - compose, - concat, - cons, - curry, - dicttoolz, - dissoc, - excepts, - functoolz, - groupby, - identity, - itertoolz, - merge, - partial, - pipe, - sliding_window, - valfilter, - valmap, - ) -except ImportError: - from toolz import ( # noqa: F401 - assoc, - complement, - compose, - concat, - cons, - curry, - dicttoolz, - dissoc, - excepts, - functoolz, - groupby, - identity, - itertoolz, - merge, - partial, - pipe, - sliding_window, - valfilter, - valmap, - ) diff --git a/web3/_utils/toolz/curried.py b/web3/_utils/toolz/curried.py deleted file mode 100644 index cf2a4449b8..0000000000 --- a/web3/_utils/toolz/curried.py +++ /dev/null @@ -1,10 +0,0 @@ -try: - from cytoolz.curried import ( - keymap, - valmap, - ) -except ImportError: - from toolz.curried import ( # noqa: F401 - keymap, - valmap, - ) diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index f39e7e7b4e..e7de55d415 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -1,13 +1,14 @@ import math -from web3._utils.threads import ( - Timeout, -) -from web3._utils.toolz import ( +from eth_utils.toolz import ( assoc, curry, merge, ) + +from web3._utils.threads import ( + Timeout, +) from web3.exceptions import ( TransactionNotFound, ) diff --git a/web3/_utils/validation.py b/web3/_utils/validation.py index 5284a1e9cd..9e322c2b7c 100644 --- a/web3/_utils/validation.py +++ b/web3/_utils/validation.py @@ -16,6 +16,12 @@ from eth_utils.hexadecimal import ( encode_hex, ) +from eth_utils.toolz import ( + compose, + groupby, + valfilter, + valmap, +) from web3._utils.abi import ( abi_to_signature, @@ -34,12 +40,6 @@ from web3._utils.formatters import ( apply_formatter_to_array, ) -from web3._utils.toolz import ( - compose, - groupby, - valfilter, - valmap, -) from web3.exceptions import ( InvalidAddress, ) diff --git a/web3/contract.py b/web3/contract.py index a3c23dba9b..d04fff9337 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -18,6 +18,10 @@ is_text, to_tuple, ) +from eth_utils.toolz import ( + compose, + partial, +) from hexbytes import ( HexBytes, ) @@ -74,10 +78,6 @@ normalize_address, normalize_bytecode, ) -from web3._utils.toolz import ( - compose, - partial, -) from web3._utils.transactions import ( fill_transaction_defaults, ) diff --git a/web3/eth.py b/web3/eth.py index 79f874e478..cbb622d6a7 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -6,6 +6,10 @@ is_checksum_address, is_string, ) +from eth_utils.toolz import ( + assoc, + merge, +) from hexbytes import ( HexBytes, ) @@ -27,10 +31,6 @@ from web3._utils.threads import ( Timeout, ) -from web3._utils.toolz import ( - assoc, - merge, -) from web3._utils.transactions import ( assert_valid_transaction_params, extract_valid_transaction_params, diff --git a/web3/gas_strategies/time_based.py b/web3/gas_strategies/time_based.py index 6b9b7f4e4d..f76a8f34af 100644 --- a/web3/gas_strategies/time_based.py +++ b/web3/gas_strategies/time_based.py @@ -5,15 +5,15 @@ from eth_utils import ( to_tuple, ) - -from web3._utils.math import ( - percentile, -) -from web3._utils.toolz import ( +from eth_utils.toolz import ( curry, groupby, sliding_window, ) + +from web3._utils.math import ( + percentile, +) from web3.exceptions import ( InsufficientData, ValidationError, diff --git a/web3/middleware/attrdict.py b/web3/middleware/attrdict.py index 4043ca3d16..21abfa36fc 100644 --- a/web3/middleware/attrdict.py +++ b/web3/middleware/attrdict.py @@ -1,10 +1,10 @@ from eth_utils import ( is_dict, ) - -from web3._utils.toolz import ( +from eth_utils.toolz import ( assoc, ) + from web3.datastructures import ( AttributeDict, ) diff --git a/web3/middleware/exception_handling.py b/web3/middleware/exception_handling.py index 1b9d14f5dc..2fa778c8f8 100644 --- a/web3/middleware/exception_handling.py +++ b/web3/middleware/exception_handling.py @@ -1,4 +1,4 @@ -from web3._utils.toolz import ( +from eth_utils.toolz import ( excepts, ) diff --git a/web3/middleware/filter.py b/web3/middleware/filter.py index 0c1cf28d83..70d0418590 100644 --- a/web3/middleware/filter.py +++ b/web3/middleware/filter.py @@ -6,8 +6,7 @@ to_hex, to_list, ) - -from web3._utils.toolz import ( +from eth_utils.toolz import ( concat, valfilter, ) diff --git a/web3/middleware/formatting.py b/web3/middleware/formatting.py index dd75ad07c4..cb25d7e827 100644 --- a/web3/middleware/formatting.py +++ b/web3/middleware/formatting.py @@ -1,4 +1,4 @@ -from web3._utils.toolz import ( +from eth_utils.toolz import ( assoc, curry, merge, diff --git a/web3/middleware/gas_price_strategy.py b/web3/middleware/gas_price_strategy.py index 4e493b8540..37feed1ed6 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 eth_utils.toolz import ( assoc, ) diff --git a/web3/middleware/geth_poa.py b/web3/middleware/geth_poa.py index aa9147e8d8..32d976a3f3 100644 --- a/web3/middleware/geth_poa.py +++ b/web3/middleware/geth_poa.py @@ -2,13 +2,13 @@ apply_formatters_to_dict, apply_key_map, ) +from eth_utils.toolz import ( + compose, +) from hexbytes import ( HexBytes, ) -from web3._utils.toolz import ( - compose, -) from web3.middleware.formatting import ( construct_formatting_middleware, ) diff --git a/web3/middleware/normalize_errors.py b/web3/middleware/normalize_errors.py index 8961cb1bd6..278297f516 100644 --- a/web3/middleware/normalize_errors.py +++ b/web3/middleware/normalize_errors.py @@ -1,4 +1,4 @@ -from web3._utils.toolz import ( +from eth_utils.toolz import ( assoc, dissoc, ) diff --git a/web3/middleware/pythonic.py b/web3/middleware/pythonic.py index b66330ce20..120017ae1d 100644 --- a/web3/middleware/pythonic.py +++ b/web3/middleware/pythonic.py @@ -12,6 +12,13 @@ text_if_str, to_checksum_address, ) +from eth_utils.toolz import ( + complement, + compose, + curried, + curry, + partial, +) from hexbytes import ( HexBytes, ) @@ -35,16 +42,6 @@ is_array_of_strings, remove_key_if, ) -from web3._utils.toolz import ( - complement, - compose, - curry, - partial, -) -from web3._utils.toolz.curried import ( - keymap, - valmap, -) from .formatting import ( construct_formatting_middleware, @@ -206,12 +203,12 @@ def to_hexbytes(num_bytes, val, variable_length=False): TRANSACTION_POOL_CONTENT_FORMATTERS = { 'pending': compose( - keymap(to_ascii_if_bytes), - valmap(transaction_formatter), + curried.keymap(to_ascii_if_bytes), + curried.valmap(transaction_formatter), ), 'queued': compose( - keymap(to_ascii_if_bytes), - valmap(transaction_formatter), + curried.keymap(to_ascii_if_bytes), + curried.valmap(transaction_formatter), ), } @@ -222,8 +219,8 @@ def to_hexbytes(num_bytes, val, variable_length=False): TRANSACTION_POOL_INSPECT_FORMATTERS = { - 'pending': keymap(to_ascii_if_bytes), - 'queued': keymap(to_ascii_if_bytes), + 'pending': curried.keymap(to_ascii_if_bytes), + 'queued': curried.keymap(to_ascii_if_bytes), } diff --git a/web3/middleware/signing.py b/web3/middleware/signing.py index 2cb64d9b17..2f261e4631 100644 --- a/web3/middleware/signing.py +++ b/web3/middleware/signing.py @@ -15,6 +15,9 @@ from eth_utils import ( to_dict, ) +from eth_utils.toolz import ( + compose, +) from web3._utils.formatters import ( apply_formatter_if, @@ -23,9 +26,6 @@ TRANSACTION_PARAMS_ABIS, apply_abi_formatters_to_dict, ) -from web3._utils.toolz import ( - compose, -) from web3._utils.transactions import ( fill_nonce, fill_transaction_defaults, diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 416ebaee99..d5ceeb3c86 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -4,16 +4,16 @@ apply_formatters_to_dict, is_null, ) -from hexbytes import ( - HexBytes, -) - -from web3._utils.toolz import ( +from eth_utils.toolz import ( complement, compose, curry, dissoc, ) +from hexbytes import ( + HexBytes, +) + from web3.exceptions import ( ValidationError, ) diff --git a/web3/parity.py b/web3/parity.py index 2ad99b408d..f84e41a33b 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -1,6 +1,9 @@ from eth_utils import ( is_checksum_address, ) +from eth_utils.toolz import ( + assoc, +) from web3._utils import ( shh, @@ -15,9 +18,6 @@ signTypedData, unlockAccount, ) -from web3._utils.toolz import ( - assoc, -) from web3.module import ( Module, ModuleV2, diff --git a/web3/providers/eth_tester/defaults.py b/web3/providers/eth_tester/defaults.py index c4c02884fb..bc803b46e6 100644 --- a/web3/providers/eth_tester/defaults.py +++ b/web3/providers/eth_tester/defaults.py @@ -14,16 +14,16 @@ is_null, keccak, ) - -from web3._utils.formatters import ( - apply_formatter_if, -) -from web3._utils.toolz import ( +from eth_utils.toolz import ( compose, curry, excepts, ) +from web3._utils.formatters import ( + apply_formatter_if, +) + def not_implemented(*args, **kwargs): raise NotImplementedError("RPC method not implemented") diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py index 804df08fbf..90a704af96 100644 --- a/web3/providers/eth_tester/middleware.py +++ b/web3/providers/eth_tester/middleware.py @@ -5,6 +5,15 @@ is_hex, is_string, ) +from eth_utils.toolz import ( + assoc, + complement, + compose, + curry, + identity, + partial, + pipe, +) from web3._utils.formatters import ( apply_formatter_if, @@ -18,15 +27,6 @@ remove_key_if, static_return, ) -from web3._utils.toolz import ( - assoc, - complement, - compose, - curry, - identity, - partial, - pipe, -) from web3.middleware import ( construct_formatting_middleware, )