Skip to content

Commit 20c62ea

Browse files
committed
Deprecate async get_uncle* methods
1 parent a370719 commit 20c62ea

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

tests/core/utilities/test_abi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def test_get_event_abi(event_name: str, input_args: Sequence[ABIComponent]) -> N
829829

830830
with pytest.warns(
831831
DeprecationWarning,
832-
match="get_event_abi is deprecated in favor of get_abi_element",
832+
match="get_event_abi is deprecated: use get_abi_element instead",
833833
):
834834
assert (
835835
get_event_abi(contract_abi, event_name, input_names) == expected_event_abi

web3/_utils/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def deprecated_for(replace_message: str) -> Callable[..., Any]:
4343
"""
4444
Decorate a deprecated function, with info about what to use instead, like:
4545
46-
@deprecated_for("to_bytes()")
46+
@deprecated_for("use to_bytes() instead")
4747
def toAscii(arg):
4848
...
4949
"""
@@ -52,7 +52,7 @@ def decorator(to_wrap: TFunc) -> TFunc:
5252
@functools.wraps(to_wrap)
5353
def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
5454
warnings.warn(
55-
f"{to_wrap.__name__} is deprecated in favor of {replace_message}",
55+
f"{to_wrap.__name__} is deprecated: {replace_message}",
5656
category=DeprecationWarning,
5757
stacklevel=2,
5858
)

web3/_utils/module_testing/eth_module.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,19 +2172,29 @@ async def test_eth_getBlockTransactionCountByHash_block_with_txn(
21722172
async def test_eth_getUncleCountByBlockHash(
21732173
self, async_w3: "AsyncWeb3", async_empty_block: BlockData
21742174
) -> None:
2175-
uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["hash"])
2175+
with pytest.warns(
2176+
DeprecationWarning,
2177+
match=r"get_uncle_count is deprecated: all get_uncle\* methods will be removed in v8",
2178+
):
2179+
uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["hash"])
21762180

2177-
assert is_integer(uncle_count)
2178-
assert uncle_count == 0
2181+
assert is_integer(uncle_count)
2182+
assert uncle_count == 0
21792183

21802184
@pytest.mark.asyncio
21812185
async def test_eth_getUncleCountByBlockNumber(
21822186
self, async_w3: "AsyncWeb3", async_empty_block: BlockData
21832187
) -> None:
2184-
uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["number"])
2188+
with pytest.warns(
2189+
DeprecationWarning,
2190+
match=r"get_uncle_count is deprecated: all get_uncle\* methods will be removed in v8",
2191+
):
2192+
uncle_count = await async_w3.eth.get_uncle_count(
2193+
async_empty_block["number"]
2194+
)
21852195

2186-
assert is_integer(uncle_count)
2187-
assert uncle_count == 0
2196+
assert is_integer(uncle_count)
2197+
assert uncle_count == 0
21882198

21892199
@pytest.mark.asyncio
21902200
async def test_eth_getBlockTransactionCountByNumber_block_with_txn(

web3/eth/async_eth.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
from web3._utils.compat import (
4040
Unpack,
4141
)
42+
from web3._utils.decorators import (
43+
deprecated_for,
44+
)
4245
from web3._utils.fee_utils import (
4346
async_fee_history_priority_fee,
4447
)
@@ -669,6 +672,7 @@ async def sign_typed_data(
669672
mungers=[default_root_munger],
670673
)
671674

675+
@deprecated_for("all get_uncle* methods will be removed in v8")
672676
async def get_uncle_count(self, block_identifier: BlockIdentifier) -> int:
673677
return await self._get_uncle_count(block_identifier)
674678

web3/utils/abi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def check_if_arguments_can_be_encoded(
682682
)
683683

684684

685-
@deprecated_for("get_abi_element")
685+
@deprecated_for("use get_abi_element instead")
686686
def get_event_abi(
687687
abi: ABI,
688688
event_name: str,

0 commit comments

Comments
 (0)