Skip to content

Commit d8996bd

Browse files
committed
Add get_uncle_count, deprecate getUncleCount
1 parent a5f05d5 commit d8996bd

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

docs/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ API
150150
- :meth:`web3.eth.get_transaction_by_block() <web3.eth.Eth.get_transaction_by_block>`
151151
- :meth:`web3.eth.getTransactionCount() <web3.eth.Eth.getTransactionCount>`
152152
- :meth:`web3.eth.get_uncle_by_block() <web3.eth.Eth.get_uncle_by_block>`
153-
- :meth:`web3.eth.getUncleCount() <web3.eth.Eth.getUncleCount>`
153+
- :meth:`web3.eth.get_uncle_count() <web3.eth.Eth.get_uncle_count>`
154154

155155

156156
Making Transactions

docs/web3.eth.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ The following methods are available on the ``web3.eth`` namespace.
505505
.. warning:: Deprecated: This method is deprecated in favor of
506506
:meth:`~web3.eth.Eth.get_uncle_by_block()`
507507

508-
.. py:method:: Eth.getUncleCount(block_identifier)
508+
.. py:method:: Eth.get_uncle_count(block_identifier)
509509
510510
* Delegates to ``eth_getUncleCountByBlockHash`` or
511511
``eth_getUncleCountByBlockNumber`` RPC methods
@@ -518,13 +518,17 @@ The following methods are available on the ``web3.eth`` namespace.
518518

519519
.. code-block:: python
520520
521-
>>> web3.eth.getUncleCount(56160)
521+
>>> web3.eth.get_uncle_count(56160)
522522
1
523523
524524
# You can also refer to the block by hash:
525-
>>> web3.eth.getUncleCount('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845')
525+
>>> web3.eth.get_uncle_count('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845')
526526
1
527527
528+
.. py:method:: Eth.getUncleCount(block_identifier)
529+
530+
.. warning:: Deprecated: This property is deprecated in favor of
531+
:attr:`~web3.eth.Eth.get_uncle_count()`
528532

529533
.. py:method:: Eth.get_transaction(transaction_hash)
530534

newsfragments/1863.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add get_uncle_count, deprecate getUncleCount

web3/_utils/module_testing/eth_module.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,33 @@ def test_eth_getBlockTransactionCountByNumber_block_with_txn_deprecated(
297297
assert transaction_count >= 1
298298

299299
def test_eth_getUncleCountByBlockHash(self, web3: "Web3", empty_block: BlockData) -> None:
300-
uncle_count = web3.eth.getUncleCount(empty_block['hash'])
300+
uncle_count = web3.eth.get_uncle_count(empty_block['hash'])
301+
302+
assert is_integer(uncle_count)
303+
assert uncle_count == 0
304+
305+
def test_eth_getUncleCountByBlockHash_deprecated(self,
306+
web3: "Web3",
307+
empty_block: BlockData) -> None:
308+
with pytest.warns(DeprecationWarning,
309+
match='getUncleCount is deprecated in favor of get_uncle_count'):
310+
uncle_count = web3.eth.getUncleCount(empty_block['hash'])
301311

302312
assert is_integer(uncle_count)
303313
assert uncle_count == 0
304314

305315
def test_eth_getUncleCountByBlockNumber(self, web3: "Web3", empty_block: BlockData) -> None:
306-
uncle_count = web3.eth.getUncleCount(empty_block['number'])
316+
uncle_count = web3.eth.get_uncle_count(empty_block['number'])
317+
318+
assert is_integer(uncle_count)
319+
assert uncle_count == 0
320+
321+
def test_eth_getUncleCountByBlockNumber_deprecated(self,
322+
web3: "Web3",
323+
empty_block: BlockData) -> None:
324+
with pytest.warns(DeprecationWarning,
325+
match='getUncleCount is deprecated in favor of get_uncle_count'):
326+
uncle_count = web3.eth.getUncleCount(empty_block['number'])
307327

308328
assert is_integer(uncle_count)
309329
assert uncle_count == 0

web3/eth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def get_block_munger(
369369
`eth_getUncleCountByBlockHash`
370370
`eth_getUncleCountByBlockNumber`
371371
"""
372-
getUncleCount: Method[Callable[[BlockIdentifier], int]] = Method(
372+
get_uncle_count: Method[Callable[[BlockIdentifier], int]] = Method(
373373
method_choice_depends_on_args=select_method_for_block_identifier(
374374
if_predefined=RPC.eth_getUncleCountByBlockNumber,
375375
if_hash=RPC.eth_getUncleCountByBlockHash,
@@ -660,3 +660,4 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None:
660660
'getTransactionByBlock',
661661
'get_transaction_by_block')
662662
getUncleByBlock = DeprecatedMethod(get_uncle_by_block, 'getUncleByBlock', 'get_uncle_by_block')
663+
getUncleCount = DeprecatedMethod(get_uncle_count, 'getUncleCount', 'get_uncle_count')

0 commit comments

Comments
 (0)