Skip to content

Commit 46fb659

Browse files
committed
Deprecate async get_uncle* methods
1 parent a370719 commit 46fb659

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

web3/_utils/module_testing/eth_module.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,19 +2172,27 @@ 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, match=r"All get_uncle\* methods have been deprecated"
2177+
):
2178+
uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["hash"])
21762179

2177-
assert is_integer(uncle_count)
2178-
assert uncle_count == 0
2180+
assert is_integer(uncle_count)
2181+
assert uncle_count == 0
21792182

21802183
@pytest.mark.asyncio
21812184
async def test_eth_getUncleCountByBlockNumber(
21822185
self, async_w3: "AsyncWeb3", async_empty_block: BlockData
21832186
) -> None:
2184-
uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["number"])
2187+
with pytest.warns(
2188+
DeprecationWarning, match=r"All get_uncle\* methods have been deprecated"
2189+
):
2190+
uncle_count = await async_w3.eth.get_uncle_count(
2191+
async_empty_block["number"]
2192+
)
21852193

2186-
assert is_integer(uncle_count)
2187-
assert uncle_count == 0
2194+
assert is_integer(uncle_count)
2195+
assert uncle_count == 0
21882196

21892197
@pytest.mark.asyncio
21902198
async def test_eth_getBlockTransactionCountByNumber_block_with_txn(

web3/eth/async_eth.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
Web3ValueError,
7272
)
7373
from web3.method import (
74+
DeprecatedMethod,
7475
Method,
7576
default_root_munger,
7677
)
@@ -660,14 +661,20 @@ async def sign_typed_data(
660661
# eth_getUncleCountByBlockHash
661662
# eth_getUncleCountByBlockNumber
662663

663-
_get_uncle_count: Method[Callable[[BlockIdentifier], Awaitable[int]]] = Method(
664+
__get_uncle_count: Method[Callable[[BlockIdentifier], Awaitable[int]]] = Method(
664665
method_choice_depends_on_args=select_method_for_block_identifier(
665666
if_predefined=RPC.eth_getUncleCountByBlockNumber,
666667
if_hash=RPC.eth_getUncleCountByBlockHash,
667668
if_number=RPC.eth_getUncleCountByBlockNumber,
668669
),
669670
mungers=[default_root_munger],
670671
)
672+
_get_uncle_count = DeprecatedMethod(
673+
__get_uncle_count,
674+
old_name="__get_uncle_count",
675+
new_name="_get_uncle_count",
676+
msg="All get_uncle* methods have been deprecated",
677+
)
671678

672679
async def get_uncle_count(self, block_identifier: BlockIdentifier) -> int:
673680
return await self._get_uncle_count(block_identifier)

0 commit comments

Comments
 (0)