web3 7.14.1__py3-none-any.whl → 8.0.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. ens/_normalization.py +23 -29
  2. ens/async_ens.py +30 -24
  3. ens/base_ens.py +2 -3
  4. ens/ens.py +18 -20
  5. ens/utils.py +6 -10
  6. web3/__init__.py +0 -4
  7. web3/_utils/abi.py +38 -40
  8. web3/_utils/async_transactions.py +6 -9
  9. web3/_utils/batching.py +11 -15
  10. web3/_utils/blocks.py +1 -2
  11. web3/_utils/caching/caching_utils.py +12 -17
  12. web3/_utils/caching/request_caching_validation.py +7 -9
  13. web3/_utils/compat/__init__.py +2 -2
  14. web3/_utils/contract_sources/compile_contracts.py +4 -6
  15. web3/_utils/contracts.py +25 -29
  16. web3/_utils/datatypes.py +6 -10
  17. web3/_utils/decorators.py +1 -3
  18. web3/_utils/encoding.py +10 -14
  19. web3/_utils/ens.py +4 -5
  20. web3/_utils/events.py +19 -24
  21. web3/_utils/filters.py +23 -29
  22. web3/_utils/formatters.py +8 -13
  23. web3/_utils/http_session_manager.py +11 -22
  24. web3/_utils/math.py +1 -2
  25. web3/_utils/method_formatters.py +41 -43
  26. web3/_utils/module.py +3 -6
  27. web3/_utils/module_testing/eth_module.py +7 -9
  28. web3/_utils/module_testing/go_ethereum_admin_module.py +1 -2
  29. web3/_utils/module_testing/module_testing_utils.py +9 -5
  30. web3/_utils/module_testing/persistent_connection_provider.py +3 -7
  31. web3/_utils/module_testing/utils.py +32 -21
  32. web3/_utils/normalizers.py +21 -24
  33. web3/_utils/rpc_abi.py +8 -11
  34. web3/_utils/threads.py +3 -4
  35. web3/_utils/transactions.py +3 -6
  36. web3/_utils/type_conversion.py +2 -6
  37. web3/_utils/utility_methods.py +5 -7
  38. web3/_utils/validation.py +6 -8
  39. web3/_utils/windows.py +1 -4
  40. web3/beacon/async_beacon.py +50 -54
  41. web3/beacon/beacon.py +50 -54
  42. web3/contract/async_contract.py +38 -46
  43. web3/contract/base_contract.py +70 -75
  44. web3/contract/contract.py +39 -43
  45. web3/contract/utils.py +47 -51
  46. web3/datastructures.py +10 -15
  47. web3/eth/async_eth.py +64 -70
  48. web3/eth/base_eth.py +40 -44
  49. web3/eth/eth.py +50 -66
  50. web3/exceptions.py +8 -13
  51. web3/gas_strategies/rpc.py +1 -7
  52. web3/gas_strategies/time_based.py +2 -3
  53. web3/geth.py +17 -17
  54. web3/main.py +43 -52
  55. web3/manager.py +32 -35
  56. web3/method.py +22 -29
  57. web3/middleware/base.py +5 -8
  58. web3/middleware/filter.py +41 -46
  59. web3/middleware/formatting.py +5 -6
  60. web3/middleware/names.py +1 -3
  61. web3/middleware/signing.py +3 -4
  62. web3/middleware/stalecheck.py +1 -2
  63. web3/middleware/validation.py +1 -2
  64. web3/module.py +11 -14
  65. web3/providers/__init__.py +0 -4
  66. web3/providers/async_base.py +21 -27
  67. web3/providers/auto.py +9 -20
  68. web3/providers/base.py +12 -17
  69. web3/providers/eth_tester/defaults.py +4 -8
  70. web3/providers/eth_tester/main.py +4 -8
  71. web3/providers/eth_tester/middleware.py +2 -4
  72. web3/providers/ipc.py +6 -10
  73. web3/providers/persistent/async_ipc.py +4 -7
  74. web3/providers/persistent/persistent.py +22 -25
  75. web3/providers/persistent/persistent_connection.py +2 -4
  76. web3/providers/persistent/request_processor.py +11 -32
  77. web3/providers/persistent/subscription_container.py +5 -8
  78. web3/providers/persistent/subscription_manager.py +13 -19
  79. web3/providers/persistent/websocket.py +15 -12
  80. web3/providers/rpc/async_rpc.py +10 -16
  81. web3/providers/rpc/rpc.py +17 -20
  82. web3/providers/rpc/utils.py +2 -3
  83. web3/scripts/release/test_package.py +1 -4
  84. web3/testing.py +1 -5
  85. web3/tracing.py +9 -13
  86. web3/types.py +51 -58
  87. web3/utils/abi.py +28 -33
  88. web3/utils/async_exception_handling.py +1 -2
  89. web3/utils/caching.py +6 -10
  90. web3/utils/exception_handling.py +1 -2
  91. web3/utils/subscriptions.py +30 -34
  92. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/METADATA +10 -9
  93. web3-8.0.0b1.dist-info/RECORD +170 -0
  94. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/WHEEL +1 -1
  95. ens/specs/.DS_Store +0 -0
  96. web3/providers/legacy_websocket.py +0 -159
  97. web3-7.14.1.dist-info/RECORD +0 -172
  98. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/licenses/LICENSE +0 -0
  99. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/top_level.txt +0 -0
web3/eth/eth.py CHANGED
@@ -2,13 +2,7 @@ from typing import (
2
2
  TYPE_CHECKING,
3
3
  Any,
4
4
  Callable,
5
- Dict,
6
- List,
7
- Optional,
8
5
  Sequence,
9
- Tuple,
10
- Type,
11
- Union,
12
6
  cast,
13
7
  overload,
14
8
  )
@@ -109,17 +103,17 @@ class Eth(BaseEth):
109
103
  # mypy types
110
104
  w3: "Web3"
111
105
 
112
- _default_contract_factory: Type[Union[Contract, ContractCaller]] = Contract
106
+ _default_contract_factory: type[Contract | ContractCaller] = Contract
113
107
 
114
108
  # eth_accounts
115
109
 
116
- _accounts: Method[Callable[[], Tuple[ChecksumAddress]]] = Method(
110
+ _accounts: Method[Callable[[], tuple[ChecksumAddress]]] = Method(
117
111
  RPC.eth_accounts,
118
112
  is_property=True,
119
113
  )
120
114
 
121
115
  @property
122
- def accounts(self) -> Tuple[ChecksumAddress]:
116
+ def accounts(self) -> tuple[ChecksumAddress]:
123
117
  return self._accounts()
124
118
 
125
119
  # eth_blobBaseFee
@@ -192,28 +186,26 @@ class Eth(BaseEth):
192
186
 
193
187
  # eth_syncing
194
188
 
195
- _syncing: Method[Callable[[], Union[SyncStatus, bool]]] = Method(
189
+ _syncing: Method[Callable[[], SyncStatus | bool]] = Method(
196
190
  RPC.eth_syncing,
197
191
  is_property=True,
198
192
  )
199
193
 
200
194
  @property
201
- def syncing(self) -> Union[SyncStatus, bool]:
195
+ def syncing(self) -> SyncStatus | bool:
202
196
  return self._syncing()
203
197
 
204
198
  # eth_feeHistory
205
199
 
206
200
  _fee_history: Method[
207
- Callable[
208
- [int, Union[BlockParams, BlockNumber], Optional[List[float]]], FeeHistory
209
- ]
201
+ Callable[[int, BlockParams | BlockNumber, list[float] | None], FeeHistory]
210
202
  ] = Method(RPC.eth_feeHistory, mungers=[default_root_munger])
211
203
 
212
204
  def fee_history(
213
205
  self,
214
206
  block_count: int,
215
- newest_block: Union[BlockParams, BlockNumber],
216
- reward_percentiles: Optional[List[float]] = None,
207
+ newest_block: BlockParams | BlockNumber,
208
+ reward_percentiles: list[float] | None = None,
217
209
  ) -> FeeHistory:
218
210
  reward_percentiles = reward_percentiles or []
219
211
  return self._fee_history(block_count, newest_block, reward_percentiles)
@@ -222,7 +214,7 @@ class Eth(BaseEth):
222
214
 
223
215
  _call: Method[
224
216
  Callable[
225
- [TxParams, Optional[BlockIdentifier], Optional[StateOverride]],
217
+ [TxParams, BlockIdentifier | None, StateOverride | None],
226
218
  HexBytes,
227
219
  ]
228
220
  ] = Method(RPC.eth_call, mungers=[BaseEth.call_munger])
@@ -230,9 +222,9 @@ class Eth(BaseEth):
230
222
  def call(
231
223
  self,
232
224
  transaction: TxParams,
233
- block_identifier: Optional[BlockIdentifier] = None,
234
- state_override: Optional[StateOverride] = None,
235
- ccip_read_enabled: Optional[bool] = None,
225
+ block_identifier: BlockIdentifier | None = None,
226
+ state_override: StateOverride | None = None,
227
+ ccip_read_enabled: bool | None = None,
236
228
  ) -> HexBytes:
237
229
  ccip_read_enabled_on_provider = self.w3.provider.global_ccip_read_enabled
238
230
  if (
@@ -251,8 +243,8 @@ class Eth(BaseEth):
251
243
  def _durin_call(
252
244
  self,
253
245
  transaction: TxParams,
254
- block_identifier: Optional[BlockIdentifier] = None,
255
- state_override: Optional[StateOverride] = None,
246
+ block_identifier: BlockIdentifier | None = None,
247
+ state_override: StateOverride | None = None,
256
248
  ) -> HexBytes:
257
249
  max_redirects = self.w3.provider.ccip_read_max_redirects
258
250
 
@@ -290,7 +282,7 @@ class Eth(BaseEth):
290
282
 
291
283
  _create_access_list: Method[
292
284
  Callable[
293
- [TxParams, Optional[BlockIdentifier]],
285
+ [TxParams, BlockIdentifier | None],
294
286
  CreateAccessListResponse,
295
287
  ]
296
288
  ] = Method(RPC.eth_createAccessList, mungers=[BaseEth.create_access_list_munger])
@@ -298,21 +290,21 @@ class Eth(BaseEth):
298
290
  def create_access_list(
299
291
  self,
300
292
  transaction: TxParams,
301
- block_identifier: Optional[BlockIdentifier] = None,
293
+ block_identifier: BlockIdentifier | None = None,
302
294
  ) -> CreateAccessListResponse:
303
295
  return self._create_access_list(transaction, block_identifier)
304
296
 
305
297
  # eth_estimateGas
306
298
 
307
299
  _estimate_gas: Method[
308
- Callable[[TxParams, Optional[BlockIdentifier], Optional[StateOverride]], int]
300
+ Callable[[TxParams, BlockIdentifier | None, StateOverride | None], int]
309
301
  ] = Method(RPC.eth_estimateGas, mungers=[BaseEth.estimate_gas_munger])
310
302
 
311
303
  def estimate_gas(
312
304
  self,
313
305
  transaction: TxParams,
314
- block_identifier: Optional[BlockIdentifier] = None,
315
- state_override: Optional[StateOverride] = None,
306
+ block_identifier: BlockIdentifier | None = None,
307
+ state_override: StateOverride | None = None,
316
308
  ) -> int:
317
309
  return self._estimate_gas(transaction, block_identifier, state_override)
318
310
 
@@ -388,12 +380,12 @@ class Eth(BaseEth):
388
380
 
389
381
  # eth_sendRawTransaction
390
382
 
391
- _send_raw_transaction: Method[Callable[[Union[HexStr, bytes]], HexBytes]] = Method(
383
+ _send_raw_transaction: Method[Callable[[HexStr | bytes], HexBytes]] = Method(
392
384
  RPC.eth_sendRawTransaction,
393
385
  mungers=[default_root_munger],
394
386
  )
395
387
 
396
- def send_raw_transaction(self, transaction: Union[HexStr, bytes]) -> HexBytes:
388
+ def send_raw_transaction(self, transaction: HexStr | bytes) -> HexBytes:
397
389
  return self._send_raw_transaction(transaction)
398
390
 
399
391
  # eth_getBlockByHash
@@ -426,7 +418,7 @@ class Eth(BaseEth):
426
418
  # eth_getBalance
427
419
 
428
420
  _get_balance: Method[
429
- Callable[[Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]], Wei]
421
+ Callable[[Address | ChecksumAddress | ENS, BlockIdentifier | None], Wei]
430
422
  ] = Method(
431
423
  RPC.eth_getBalance,
432
424
  mungers=[BaseEth.block_id_munger],
@@ -434,44 +426,40 @@ class Eth(BaseEth):
434
426
 
435
427
  def get_balance(
436
428
  self,
437
- account: Union[Address, ChecksumAddress, ENS],
438
- block_identifier: Optional[BlockIdentifier] = None,
429
+ account: Address | ChecksumAddress | ENS,
430
+ block_identifier: BlockIdentifier | None = None,
439
431
  ) -> Wei:
440
432
  return self._get_balance(account, block_identifier)
441
433
 
442
434
  # eth_getCode
443
435
 
444
436
  _get_code: Method[
445
- Callable[
446
- [Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]], HexBytes
447
- ]
437
+ Callable[[Address | ChecksumAddress | ENS, BlockIdentifier | None], HexBytes]
448
438
  ] = Method(RPC.eth_getCode, mungers=[BaseEth.block_id_munger])
449
439
 
450
440
  def get_code(
451
441
  self,
452
- account: Union[Address, ChecksumAddress, ENS],
453
- block_identifier: Optional[BlockIdentifier] = None,
442
+ account: Address | ChecksumAddress | ENS,
443
+ block_identifier: BlockIdentifier | None = None,
454
444
  ) -> HexBytes:
455
445
  return self._get_code(account, block_identifier)
456
446
 
457
447
  # eth_getLogs
458
448
 
459
- _get_logs: Method[Callable[[FilterParams], List[LogReceipt]]] = Method(
449
+ _get_logs: Method[Callable[[FilterParams], list[LogReceipt]]] = Method(
460
450
  RPC.eth_getLogs, mungers=[default_root_munger]
461
451
  )
462
452
 
463
453
  def get_logs(
464
454
  self,
465
455
  filter_params: FilterParams,
466
- ) -> List[LogReceipt]:
456
+ ) -> list[LogReceipt]:
467
457
  return self._get_logs(filter_params)
468
458
 
469
459
  # eth_getTransactionCount
470
460
 
471
461
  _get_transaction_count: Method[
472
- Callable[
473
- [Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]], Nonce
474
- ]
462
+ Callable[[Address | ChecksumAddress | ENS, BlockIdentifier | None], Nonce]
475
463
  ] = Method(
476
464
  RPC.eth_getTransactionCount,
477
465
  mungers=[BaseEth.block_id_munger],
@@ -479,8 +467,8 @@ class Eth(BaseEth):
479
467
 
480
468
  def get_transaction_count(
481
469
  self,
482
- account: Union[Address, ChecksumAddress, ENS],
483
- block_identifier: Optional[BlockIdentifier] = None,
470
+ account: Address | ChecksumAddress | ENS,
471
+ block_identifier: BlockIdentifier | None = None,
484
472
  ) -> Nonce:
485
473
  return self._get_transaction_count(account, block_identifier)
486
474
 
@@ -518,7 +506,7 @@ class Eth(BaseEth):
518
506
 
519
507
  _get_storage_at: Method[
520
508
  Callable[
521
- [Union[Address, ChecksumAddress, ENS], int, Optional[BlockIdentifier]],
509
+ [Address | ChecksumAddress | ENS, int, BlockIdentifier | None],
522
510
  HexBytes,
523
511
  ]
524
512
  ] = Method(
@@ -528,9 +516,9 @@ class Eth(BaseEth):
528
516
 
529
517
  def get_storage_at(
530
518
  self,
531
- account: Union[Address, ChecksumAddress, ENS],
519
+ account: Address | ChecksumAddress | ENS,
532
520
  position: int,
533
- block_identifier: Optional[BlockIdentifier] = None,
521
+ block_identifier: BlockIdentifier | None = None,
534
522
  ) -> HexBytes:
535
523
  return self._get_storage_at(account, position, block_identifier)
536
524
 
@@ -538,12 +526,10 @@ class Eth(BaseEth):
538
526
 
539
527
  def get_proof_munger(
540
528
  self,
541
- account: Union[Address, ChecksumAddress, ENS],
529
+ account: Address | ChecksumAddress | ENS,
542
530
  positions: Sequence[int],
543
- block_identifier: Optional[BlockIdentifier] = None,
544
- ) -> Tuple[
545
- Union[Address, ChecksumAddress, ENS], Sequence[int], Optional[BlockIdentifier]
546
- ]:
531
+ block_identifier: BlockIdentifier | None = None,
532
+ ) -> tuple[Address | ChecksumAddress | ENS, Sequence[int], BlockIdentifier | None]:
547
533
  if block_identifier is None:
548
534
  block_identifier = self.default_block
549
535
  return (account, positions, block_identifier)
@@ -551,10 +537,10 @@ class Eth(BaseEth):
551
537
  get_proof: Method[
552
538
  Callable[
553
539
  [
554
- Tuple[
555
- Union[Address, ChecksumAddress, ENS],
540
+ tuple[
541
+ Address | ChecksumAddress | ENS,
556
542
  Sequence[int],
557
- Optional[BlockIdentifier],
543
+ BlockIdentifier | None,
558
544
  ]
559
545
  ],
560
546
  MerkleProof,
@@ -633,7 +619,7 @@ class Eth(BaseEth):
633
619
  # eth_signTypedData
634
620
 
635
621
  sign_typed_data: Method[
636
- Callable[[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], HexStr]
622
+ Callable[[Address | ChecksumAddress | ENS, dict[str, Any]], HexStr]
637
623
  ] = Method(
638
624
  RPC.eth_signTypedData,
639
625
  mungers=[default_root_munger],
@@ -641,9 +627,7 @@ class Eth(BaseEth):
641
627
 
642
628
  # eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
643
629
 
644
- filter: Method[
645
- Callable[[Optional[Union[str, FilterParams, HexStr]]], Filter]
646
- ] = Method(
630
+ filter: Method[Callable[[str | FilterParams | HexStr | None], Filter]] = Method(
647
631
  method_choice_depends_on_args=select_filter_method(
648
632
  if_new_block_filter=RPC.eth_newBlockFilter,
649
633
  if_new_pending_transaction_filter=RPC.eth_newPendingTransactionFilter,
@@ -654,11 +638,11 @@ class Eth(BaseEth):
654
638
 
655
639
  # eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
656
640
 
657
- get_filter_changes: Method[Callable[[HexStr], List[LogReceipt]]] = Method(
641
+ get_filter_changes: Method[Callable[[HexStr], list[LogReceipt]]] = Method(
658
642
  RPC.eth_getFilterChanges, mungers=[default_root_munger]
659
643
  )
660
644
 
661
- get_filter_logs: Method[Callable[[HexStr], List[LogReceipt]]] = Method(
645
+ get_filter_logs: Method[Callable[[HexStr], list[LogReceipt]]] = Method(
662
646
  RPC.eth_getFilterLogs, mungers=[default_root_munger]
663
647
  )
664
648
 
@@ -668,20 +652,20 @@ class Eth(BaseEth):
668
652
  )
669
653
 
670
654
  @overload
671
- def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]:
655
+ def contract(self, address: None = None, **kwargs: Any) -> type[Contract]:
672
656
  ...
673
657
 
674
658
  @overload
675
659
  def contract(
676
- self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
660
+ self, address: Address | ChecksumAddress | ENS, **kwargs: Any
677
661
  ) -> Contract:
678
662
  ...
679
663
 
680
664
  def contract(
681
665
  self,
682
- address: Optional[Union[Address, ChecksumAddress, ENS]] = None,
666
+ address: Address | ChecksumAddress | ENS | None = None,
683
667
  **kwargs: Any,
684
- ) -> Union[Type[Contract], Contract]:
668
+ ) -> type[Contract] | Contract:
685
669
  ContractFactoryClass = kwargs.pop(
686
670
  "ContractFactoryClass", self._default_contract_factory
687
671
  )
@@ -695,6 +679,6 @@ class Eth(BaseEth):
695
679
 
696
680
  def set_contract_factory(
697
681
  self,
698
- contract_factory: Type[Union[Contract, ContractCaller]],
682
+ contract_factory: type[Contract | ContractCaller],
699
683
  ) -> None:
700
684
  self._default_contract_factory = contract_factory
web3/exceptions.py CHANGED
@@ -3,9 +3,6 @@ import time
3
3
  from typing import (
4
4
  TYPE_CHECKING,
5
5
  Any,
6
- Dict,
7
- Optional,
8
- Union,
9
6
  )
10
7
 
11
8
  from web3.types import (
@@ -31,12 +28,12 @@ class Web3Exception(Exception):
31
28
  # deal with other exceptions
32
29
  """
33
30
 
34
- user_message: Optional[str] = None
31
+ user_message: str | None = None
35
32
 
36
33
  def __init__(
37
34
  self,
38
35
  *args: Any,
39
- user_message: Optional[str] = None,
36
+ user_message: str | None = None,
40
37
  ):
41
38
  super().__init__(*args)
42
39
 
@@ -261,8 +258,8 @@ class ContractLogicError(Web3Exception):
261
258
 
262
259
  def __init__(
263
260
  self,
264
- message: Optional[str] = None,
265
- data: Optional[Union[str, Dict[str, str]]] = None,
261
+ message: str | None = None,
262
+ data: str | dict[str, str] | None = None,
266
263
  ):
267
264
  super().__init__(message, data)
268
265
  self.message = message
@@ -286,7 +283,7 @@ class OffchainLookup(ContractLogicError):
286
283
  Raised when a contract reverts with OffchainLookup as described in EIP-3668
287
284
  """
288
285
 
289
- def __init__(self, payload: Dict[str, Any], data: Optional[str] = None) -> None:
286
+ def __init__(self, payload: dict[str, Any], data: str | None = None) -> None:
290
287
  self.payload = payload
291
288
  self.data = data
292
289
  super().__init__(data=data)
@@ -324,9 +321,7 @@ class TaskNotRunning(Web3Exception):
324
321
  is not currently running.
325
322
  """
326
323
 
327
- def __init__(
328
- self, task: "asyncio.Task[Any]", message: Optional[str] = None
329
- ) -> None:
324
+ def __init__(self, task: "asyncio.Task[Any]", message: str | None = None) -> None:
330
325
  self.task = task
331
326
  if message is None:
332
327
  message = f"Task {task} is not running."
@@ -375,8 +370,8 @@ class Web3RPCError(Web3Exception):
375
370
  def __init__(
376
371
  self,
377
372
  message: str,
378
- rpc_response: Optional[RPCResponse] = None,
379
- user_message: Optional[str] = None,
373
+ rpc_response: RPCResponse | None = None,
374
+ user_message: str | None = None,
380
375
  ) -> None:
381
376
  if user_message is None:
382
377
  user_message = (
@@ -1,7 +1,3 @@
1
- from typing import (
2
- Optional,
3
- )
4
-
5
1
  from web3 import (
6
2
  Web3,
7
3
  )
@@ -11,9 +7,7 @@ from web3.types import (
11
7
  )
12
8
 
13
9
 
14
- def rpc_gas_price_strategy(
15
- w3: Web3, transaction_params: Optional[TxParams] = None
16
- ) -> Wei:
10
+ def rpc_gas_price_strategy(w3: Web3, transaction_params: TxParams | None = None) -> Wei:
17
11
  """
18
12
  A simple gas price strategy deriving its value from the eth_gasPrice JSON-RPC call.
19
13
  """
@@ -4,7 +4,6 @@ import operator
4
4
  from typing import (
5
5
  Iterable,
6
6
  Sequence,
7
- Tuple,
8
7
  cast,
9
8
  )
10
9
 
@@ -82,7 +81,7 @@ def _get_weighted_avg_block_time(w3: Web3, sample_size: int) -> float:
82
81
 
83
82
  def _get_raw_miner_data(
84
83
  w3: Web3, sample_size: int
85
- ) -> Iterable[Tuple[ChecksumAddress, HexBytes, Wei]]:
84
+ ) -> Iterable[tuple[ChecksumAddress, HexBytes, Wei]]:
86
85
  latest = w3.eth.get_block("latest", full_transactions=True)
87
86
 
88
87
  for transaction in latest["transactions"]:
@@ -104,7 +103,7 @@ def _get_raw_miner_data(
104
103
 
105
104
 
106
105
  def _aggregate_miner_data(
107
- raw_data: Iterable[Tuple[ChecksumAddress, HexBytes, Wei]],
106
+ raw_data: Iterable[tuple[ChecksumAddress, HexBytes, Wei]],
108
107
  ) -> Iterable[MinerData]:
109
108
  data_by_miner = groupby(0, raw_data)
110
109
 
web3/geth.py CHANGED
@@ -1,11 +1,7 @@
1
1
  from typing import (
2
2
  Awaitable,
3
3
  Callable,
4
- List,
5
- Optional,
6
4
  Protocol,
7
- Tuple,
8
- Union,
9
5
  )
10
6
 
11
7
  from eth_typing.evm import (
@@ -44,7 +40,7 @@ class UnlockAccountWrapper(Protocol):
44
40
  self,
45
41
  account: ChecksumAddress,
46
42
  passphrase: str,
47
- duration: Optional[int] = None,
43
+ duration: int | None = None,
48
44
  ) -> bool:
49
45
  pass
50
46
 
@@ -89,7 +85,7 @@ def admin_start_params_munger(
89
85
  port: int = 8546,
90
86
  cors: str = "",
91
87
  apis: str = "eth,net,web3",
92
- ) -> Tuple[str, int, str, str]:
88
+ ) -> tuple[str, int, str, str]:
93
89
  return (host, port, cors, apis)
94
90
 
95
91
 
@@ -115,7 +111,7 @@ class GethAdmin(Module):
115
111
  is_property=True,
116
112
  )
117
113
 
118
- peers: Method[Callable[[], List[Peer]]] = Method(
114
+ peers: Method[Callable[[], list[Peer]]] = Method(
119
115
  RPC.admin_peers,
120
116
  is_property=True,
121
117
  )
@@ -149,14 +145,14 @@ class GethDebug(Module):
149
145
  def trace_transaction_munger(
150
146
  self,
151
147
  transaction_hash: _Hash32,
152
- trace_config: Optional[TraceConfig] = None,
153
- ) -> Tuple[_Hash32, TraceConfig]:
148
+ trace_config: TraceConfig | None = None,
149
+ ) -> tuple[_Hash32, TraceConfig]:
154
150
  return (transaction_hash, trace_config)
155
151
 
156
152
  trace_transaction: Method[
157
153
  Callable[
158
154
  ...,
159
- Union[CallTrace, PrestateTrace, OpcodeTrace, DiffModeTrace, FourByteTrace],
155
+ CallTrace | PrestateTrace | OpcodeTrace | DiffModeTrace | FourByteTrace,
160
156
  ]
161
157
  ] = Method(
162
158
  RPC.debug_traceTransaction,
@@ -236,12 +232,12 @@ class AsyncGethAdmin(Module):
236
232
  async def node_info(self) -> NodeInfo:
237
233
  return await self._node_info()
238
234
 
239
- _peers: Method[Callable[[], Awaitable[List[Peer]]]] = Method(
235
+ _peers: Method[Callable[[], Awaitable[list[Peer]]]] = Method(
240
236
  RPC.admin_peers,
241
237
  is_property=True,
242
238
  )
243
239
 
244
- async def peers(self) -> List[Peer]:
240
+ async def peers(self) -> list[Peer]:
245
241
  return await self._peers()
246
242
 
247
243
  # start_http and stop_http
@@ -304,9 +300,13 @@ class AsyncGethDebug(Module):
304
300
  Callable[
305
301
  ...,
306
302
  Awaitable[
307
- Union[
308
- CallTrace, PrestateTrace, OpcodeTrace, FourByteTrace, DiffModeTrace
309
- ]
303
+ (
304
+ CallTrace
305
+ | PrestateTrace
306
+ | OpcodeTrace
307
+ | FourByteTrace
308
+ | DiffModeTrace
309
+ )
310
310
  ],
311
311
  ]
312
312
  ] = Method(RPC.debug_traceTransaction)
@@ -314,8 +314,8 @@ class AsyncGethDebug(Module):
314
314
  async def trace_transaction(
315
315
  self,
316
316
  transaction_hash: _Hash32,
317
- trace_config: Optional[TraceConfig] = None,
318
- ) -> Union[CallTrace, PrestateTrace, OpcodeTrace, FourByteTrace, DiffModeTrace]:
317
+ trace_config: TraceConfig | None = None,
318
+ ) -> CallTrace | PrestateTrace | OpcodeTrace | FourByteTrace | DiffModeTrace:
319
319
  return await self._trace_transaction(transaction_hash, trace_config)
320
320
 
321
321