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
ens/_normalization.py CHANGED
@@ -5,13 +5,7 @@ import json
5
5
  import os
6
6
  from typing import (
7
7
  Any,
8
- Dict,
9
- List,
10
8
  Literal,
11
- Optional,
12
- Set,
13
- Tuple,
14
- Union,
15
9
  )
16
10
 
17
11
  from pyunormalize import (
@@ -27,9 +21,9 @@ from .exceptions import (
27
21
 
28
22
 
29
23
  def _json_list_mapping_to_dict(
30
- f: Dict[str, Any],
24
+ f: dict[str, Any],
31
25
  list_mapped_key: str,
32
- ) -> Dict[str, Any]:
26
+ ) -> dict[str, Any]:
33
27
  """
34
28
  Takes a `[key, [value]]` mapping from the original ENS spec json files and turns it
35
29
  into a `{key: value}` mapping.
@@ -67,17 +61,17 @@ class TokenType(Enum):
67
61
  class Token:
68
62
  type: Literal[TokenType.TEXT, TokenType.EMOJI]
69
63
  _original_text: str
70
- _original_codepoints: List[int]
71
- _normalized_codepoints: Optional[List[int]] = None
64
+ _original_codepoints: list[int]
65
+ _normalized_codepoints: list[int] | None = None
72
66
 
73
67
  restricted: bool = False
74
68
 
75
- def __init__(self, codepoints: List[int]) -> None:
69
+ def __init__(self, codepoints: list[int]) -> None:
76
70
  self._original_codepoints = codepoints
77
71
  self._original_text = "".join(chr(cp) for cp in codepoints)
78
72
 
79
73
  @property
80
- def codepoints(self) -> List[int]:
74
+ def codepoints(self) -> list[int]:
81
75
  return (
82
76
  self._normalized_codepoints
83
77
  if self._normalized_codepoints
@@ -99,12 +93,12 @@ class TextToken(Token):
99
93
 
100
94
  class Label:
101
95
  type: str
102
- tokens: List[Token]
96
+ tokens: list[Token]
103
97
 
104
98
  def __init__(
105
99
  self,
106
100
  type: str = None,
107
- tokens: List[Token] = None,
101
+ tokens: list[Token] = None,
108
102
  ) -> None:
109
103
  self.type = type
110
104
  self.tokens = tokens
@@ -118,9 +112,9 @@ class Label:
118
112
 
119
113
 
120
114
  class ENSNormalizedName:
121
- labels: List[Label]
115
+ labels: list[Label]
122
116
 
123
- def __init__(self, normalized_labels: List[Label]) -> None:
117
+ def __init__(self, normalized_labels: list[Label]) -> None:
124
118
  self.labels = normalized_labels
125
119
 
126
120
  @property
@@ -140,7 +134,7 @@ VALID_BY_GROUPS = {
140
134
  }
141
135
 
142
136
 
143
- def _extract_valid_codepoints() -> Set[int]:
137
+ def _extract_valid_codepoints() -> set[int]:
144
138
  all_valid = set()
145
139
  for _name, valid_cps in VALID_BY_GROUPS.items():
146
140
  all_valid.update(valid_cps)
@@ -148,20 +142,20 @@ def _extract_valid_codepoints() -> Set[int]:
148
142
  return all_valid
149
143
 
150
144
 
151
- def _construct_whole_confusable_map() -> Dict[int, Set[str]]:
145
+ def _construct_whole_confusable_map() -> dict[int, set[str]]:
152
146
  """
153
147
  Create a mapping, per confusable, that contains all the groups in the cp's whole
154
148
  confusable excluding the confusable extent of the cp itself - as per the spec at
155
149
  https://docs.ens.domains/ens-improvement-proposals/ensip-15-normalization-standard
156
150
  """
157
- whole_map: Dict[int, Set[str]] = {}
151
+ whole_map: dict[int, set[str]] = {}
158
152
  for whole in NORMALIZATION_SPEC["wholes"]:
159
- whole_confusables: Set[int] = set(whole["valid"] + whole["confused"])
160
- confusable_extents: List[Tuple[Set[int], Set[str]]] = []
153
+ whole_confusables: set[int] = set(whole["valid"] + whole["confused"])
154
+ confusable_extents: list[tuple[set[int], set[str]]] = []
161
155
 
162
156
  for confusable_cp in whole_confusables:
163
157
  # create confusable extents for all whole confusables
164
- groups: Set[str] = set()
158
+ groups: set[str] = set()
165
159
  for gn, gv in VALID_BY_GROUPS.items():
166
160
  if confusable_cp in gv:
167
161
  groups.add(gn)
@@ -181,7 +175,7 @@ def _construct_whole_confusable_map() -> Dict[int, Set[str]]:
181
175
  confusable_extents.append(({confusable_cp}, groups))
182
176
 
183
177
  for confusable_cp in whole_confusables:
184
- confusable_cp_extent_groups: Set[str] = set()
178
+ confusable_cp_extent_groups: set[str] = set()
185
179
 
186
180
  if confusable_cp in whole["confused"]:
187
181
  whole_map[confusable_cp] = set()
@@ -209,13 +203,13 @@ def _is_fenced(cp: int) -> bool:
209
203
  return cp in [fenced[0] for fenced in NORMALIZATION_SPEC["fenced"]]
210
204
 
211
205
 
212
- def _codepoints_to_text(cps: Union[List[List[int]], List[int]]) -> str:
206
+ def _codepoints_to_text(cps: list[list[int]] | list[int]) -> str:
213
207
  return "".join(
214
208
  chr(cp) if isinstance(cp, int) else _codepoints_to_text(cp) for cp in cps
215
209
  )
216
210
 
217
211
 
218
- def _validate_tokens_and_get_label_type(tokens: List[Token]) -> str:
212
+ def _validate_tokens_and_get_label_type(tokens: list[Token]) -> str:
219
213
  """
220
214
  Validate tokens and return the label type.
221
215
 
@@ -388,7 +382,7 @@ def _validate_tokens_and_get_label_type(tokens: List[Token]) -> str:
388
382
  return chars_group_name
389
383
 
390
384
 
391
- def _build_and_validate_label_from_tokens(tokens: List[Token]) -> Label:
385
+ def _build_and_validate_label_from_tokens(tokens: list[Token]) -> Label:
392
386
  for token in tokens:
393
387
  if token.type == TokenType.TEXT:
394
388
  # apply NFC normalization to text tokens
@@ -404,7 +398,7 @@ def _build_and_validate_label_from_tokens(tokens: List[Token]) -> Label:
404
398
  return label
405
399
 
406
400
 
407
- def _buffer_codepoints_to_chars(buffer: Union[List[int], List[List[int]]]) -> str:
401
+ def _buffer_codepoints_to_chars(buffer: list[int] | list[list[int]]) -> str:
408
402
  return "".join(
409
403
  "".join(chr(c) for c in char) if isinstance(char, list) else chr(char)
410
404
  for char in buffer
@@ -438,8 +432,8 @@ def normalize_name_ensip15(name: str) -> ENSNormalizedName:
438
432
  # _input takes the label and breaks it into a list of unicode code points
439
433
  # e.g. "xyz👨🏻" -> [120, 121, 122, 128104, 127995]
440
434
  _input = [ord(c) for c in label_str]
441
- buffer: List[int] = []
442
- tokens: List[Token] = []
435
+ buffer: list[int] = []
436
+ tokens: list[Token] = []
443
437
 
444
438
  while len(_input) > 0:
445
439
  emoji_codepoint = None
ens/async_ens.py CHANGED
@@ -7,8 +7,6 @@ from typing import (
7
7
  Coroutine,
8
8
  Optional,
9
9
  Sequence,
10
- Tuple,
11
- Union,
12
10
  cast,
13
11
  )
14
12
 
@@ -103,8 +101,8 @@ class AsyncENS(BaseENS):
103
101
  def __init__(
104
102
  self,
105
103
  provider: Optional["AsyncBaseProvider"] = None,
106
- addr: Optional[ChecksumAddress] = None,
107
- middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
104
+ addr: ChecksumAddress | None = None,
105
+ middleware: Sequence[tuple["Middleware", str]] | None = None,
108
106
  ) -> None:
109
107
  """
110
108
  :param provider: a single provider used to connect to Ethereum
@@ -137,7 +135,11 @@ class AsyncENS(BaseENS):
137
135
  """
138
136
  provider = w3.manager.provider
139
137
  middleware = w3.middleware_onion.middleware
140
- ns = cls(cast("AsyncBaseProvider", provider), addr=addr, middleware=middleware)
138
+ ns = cls(
139
+ cast("AsyncBaseProvider", provider),
140
+ addr=addr,
141
+ middleware=middleware,
142
+ )
141
143
 
142
144
  # inherit strict bytes checking from w3 instance
143
145
  ns.strict_bytes_type_checking = w3.strict_bytes_type_checking
@@ -147,8 +149,8 @@ class AsyncENS(BaseENS):
147
149
  async def address(
148
150
  self,
149
151
  name: str,
150
- coin_type: Optional[int] = None,
151
- ) -> Optional[ChecksumAddress]:
152
+ coin_type: int | None = None,
153
+ ) -> ChecksumAddress | None:
152
154
  """
153
155
  Look up the Ethereum address that `name` currently points to.
154
156
 
@@ -163,7 +165,10 @@ class AsyncENS(BaseENS):
163
165
  else:
164
166
  r = await self.resolver(name)
165
167
  await _async_validate_resolver_and_interface_id(
166
- name, r, ENS_MULTICHAIN_ADDRESS_INTERFACE_ID, "addr(bytes32,uint256)"
168
+ name,
169
+ r,
170
+ ENS_MULTICHAIN_ADDRESS_INTERFACE_ID,
171
+ "addr(bytes32,uint256)",
167
172
  )
168
173
  node = raw_name_to_hash(name)
169
174
  address_as_bytes = await r.caller.addr(node, coin_type)
@@ -174,12 +179,12 @@ class AsyncENS(BaseENS):
174
179
  async def setup_address(
175
180
  self,
176
181
  name: str,
177
- address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
178
- ChecksumAddress, default
179
- ),
180
- coin_type: Optional[int] = None,
182
+ address: Address
183
+ | ChecksumAddress
184
+ | HexAddress = cast(ChecksumAddress, default), # noqa: B008
185
+ coin_type: int | None = None,
181
186
  transact: Optional["TxParams"] = None,
182
- ) -> Optional[HexBytes]:
187
+ ) -> HexBytes | None:
183
188
  """
184
189
  Set up the name to point to the supplied address.
185
190
  The sender of the transaction must own the name, or
@@ -228,7 +233,7 @@ class AsyncENS(BaseENS):
228
233
  transact
229
234
  )
230
235
 
231
- async def name(self, address: ChecksumAddress) -> Optional[str]:
236
+ async def name(self, address: ChecksumAddress) -> str | None:
232
237
  """
233
238
  Look up the name that the address points to, using a
234
239
  reverse lookup. Reverse lookup is opt-in for name owners.
@@ -248,7 +253,7 @@ class AsyncENS(BaseENS):
248
253
  async def setup_name(
249
254
  self,
250
255
  name: str,
251
- address: Optional[ChecksumAddress] = None,
256
+ address: ChecksumAddress | None = None,
252
257
  transact: Optional["TxParams"] = None,
253
258
  ) -> HexBytes:
254
259
  """
@@ -314,7 +319,7 @@ class AsyncENS(BaseENS):
314
319
  name: str,
315
320
  new_owner: ChecksumAddress = None,
316
321
  transact: Optional["TxParams"] = None,
317
- ) -> Optional[ChecksumAddress]:
322
+ ) -> ChecksumAddress | None:
318
323
  """
319
324
  Set the owner of the supplied name to `new_owner`.
320
325
 
@@ -437,7 +442,7 @@ class AsyncENS(BaseENS):
437
442
  self,
438
443
  normal_name: str,
439
444
  fn_name: str = "addr",
440
- ) -> Tuple[Optional["AsyncContract"], str]:
445
+ ) -> tuple[Optional["AsyncContract"], str]:
441
446
  current_name = normal_name
442
447
 
443
448
  # look for a resolver, starting at the full name and taking the
@@ -454,7 +459,8 @@ class AsyncENS(BaseENS):
454
459
  if not is_none_or_zero_address(resolver_addr):
455
460
  # if resolver found, return it
456
461
  resolver = cast(
457
- "AsyncContract", self._type_aware_resolver(resolver_addr, fn_name)
462
+ "AsyncContract",
463
+ self._type_aware_resolver(resolver_addr, fn_name),
458
464
  )
459
465
  return resolver, current_name
460
466
 
@@ -464,7 +470,7 @@ class AsyncENS(BaseENS):
464
470
  async def _set_resolver(
465
471
  self,
466
472
  name: str,
467
- resolver_addr: Optional[ChecksumAddress] = None,
473
+ resolver_addr: ChecksumAddress | None = None,
468
474
  transact: Optional["TxParams"] = None,
469
475
  ) -> "AsyncContract":
470
476
  if not transact:
@@ -487,7 +493,7 @@ class AsyncENS(BaseENS):
487
493
  self,
488
494
  name: str,
489
495
  fn_name: str = "addr",
490
- ) -> Optional[Union[ChecksumAddress, str]]:
496
+ ) -> ChecksumAddress | str | None:
491
497
  normal_name = normalize_name(name)
492
498
 
493
499
  resolver, current_name = await self._get_resolver(normal_name, fn_name)
@@ -523,7 +529,7 @@ class AsyncENS(BaseENS):
523
529
  self,
524
530
  account: ChecksumAddress,
525
531
  name: str,
526
- parent_owned: Optional[str] = None,
532
+ parent_owned: str | None = None,
527
533
  ) -> None:
528
534
  if not address_in(account, await self.w3.eth.accounts):
529
535
  raise UnauthorizedError(
@@ -533,7 +539,7 @@ class AsyncENS(BaseENS):
533
539
 
534
540
  async def _first_owner(
535
541
  self, name: str
536
- ) -> Tuple[Optional[ChecksumAddress], Sequence[str], str]:
542
+ ) -> tuple[ChecksumAddress | None, Sequence[str], str]:
537
543
  """
538
544
  Takes a name, and returns the owner of the deepest subdomain that has an owner
539
545
 
@@ -554,7 +560,7 @@ class AsyncENS(BaseENS):
554
560
  owner: ChecksumAddress,
555
561
  unowned: Sequence[str],
556
562
  owned: str,
557
- old_owner: Optional[ChecksumAddress] = None,
563
+ old_owner: ChecksumAddress | None = None,
558
564
  transact: Optional["TxParams"] = None,
559
565
  ) -> None:
560
566
  if not transact:
@@ -575,7 +581,7 @@ class AsyncENS(BaseENS):
575
581
 
576
582
  async def _setup_reverse(
577
583
  self,
578
- name: Optional[str],
584
+ name: str | None,
579
585
  address: ChecksumAddress,
580
586
  transact: Optional["TxParams"] = None,
581
587
  ) -> HexBytes:
ens/base_ens.py CHANGED
@@ -4,7 +4,6 @@ from functools import (
4
4
  from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
- Type,
8
7
  Union,
9
8
  )
10
9
 
@@ -40,8 +39,8 @@ if TYPE_CHECKING:
40
39
  class BaseENS:
41
40
  w3: Union["AsyncWeb3[Any]", "Web3"] = None
42
41
  ens: Union["Contract", "AsyncContract"] = None
43
- _resolver_contract: Union[Type["Contract"], Type["AsyncContract"]] = None
44
- _reverse_resolver_contract: Union[Type["Contract"], Type["AsyncContract"]] = None
42
+ _resolver_contract: type["Contract"] | type["AsyncContract"] = None
43
+ _reverse_resolver_contract: type["Contract"] | type["AsyncContract"] = None
45
44
 
46
45
  @property
47
46
  def strict_bytes_type_checking(self) -> bool:
ens/ens.py CHANGED
@@ -6,8 +6,6 @@ from typing import (
6
6
  Any,
7
7
  Optional,
8
8
  Sequence,
9
- Tuple,
10
- Union,
11
9
  cast,
12
10
  )
13
11
 
@@ -100,7 +98,7 @@ class ENS(BaseENS):
100
98
  self,
101
99
  provider: "BaseProvider" = None,
102
100
  addr: ChecksumAddress = None,
103
- middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
101
+ middleware: Sequence[tuple["Middleware", str]] | None = None,
104
102
  ) -> None:
105
103
  """
106
104
  :param provider: a single provider used to connect to Ethereum
@@ -142,8 +140,8 @@ class ENS(BaseENS):
142
140
  def address(
143
141
  self,
144
142
  name: str,
145
- coin_type: Optional[int] = None,
146
- ) -> Optional[ChecksumAddress]:
143
+ coin_type: int | None = None,
144
+ ) -> ChecksumAddress | None:
147
145
  """
148
146
  Look up the Ethereum address that `name` currently points to.
149
147
 
@@ -172,12 +170,12 @@ class ENS(BaseENS):
172
170
  def setup_address(
173
171
  self,
174
172
  name: str,
175
- address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
176
- ChecksumAddress, default
177
- ),
178
- coin_type: Optional[int] = None,
173
+ address: Address
174
+ | ChecksumAddress
175
+ | HexAddress = cast(ChecksumAddress, default), # noqa: B008
176
+ coin_type: int | None = None,
179
177
  transact: Optional["TxParams"] = None,
180
- ) -> Optional[HexBytes]:
178
+ ) -> HexBytes | None:
181
179
  """
182
180
  Set up the name to point to the supplied address.
183
181
  The sender of the transaction must own the name, or
@@ -227,7 +225,7 @@ class ENS(BaseENS):
227
225
  transact
228
226
  )
229
227
 
230
- def name(self, address: ChecksumAddress) -> Optional[str]:
228
+ def name(self, address: ChecksumAddress) -> str | None:
231
229
  """
232
230
  Look up the name that the address points to, using a
233
231
  reverse lookup. Reverse lookup is opt-in for name owners.
@@ -245,7 +243,7 @@ class ENS(BaseENS):
245
243
  def setup_name(
246
244
  self,
247
245
  name: str,
248
- address: Optional[ChecksumAddress] = None,
246
+ address: ChecksumAddress | None = None,
249
247
  transact: Optional["TxParams"] = None,
250
248
  ) -> HexBytes:
251
249
  """
@@ -311,7 +309,7 @@ class ENS(BaseENS):
311
309
  name: str,
312
310
  new_owner: ChecksumAddress = None,
313
311
  transact: Optional["TxParams"] = None,
314
- ) -> Optional[ChecksumAddress]:
312
+ ) -> ChecksumAddress | None:
315
313
  """
316
314
  Set the owner of the supplied name to `new_owner`.
317
315
 
@@ -428,7 +426,7 @@ class ENS(BaseENS):
428
426
  self,
429
427
  normal_name: str,
430
428
  fn_name: str = "addr",
431
- ) -> Tuple[Optional["Contract"], str]:
429
+ ) -> tuple[Optional["Contract"], str]:
432
430
  current_name = normal_name
433
431
 
434
432
  # look for a resolver, starting at the full name and taking the parent
@@ -453,7 +451,7 @@ class ENS(BaseENS):
453
451
  def _set_resolver(
454
452
  self,
455
453
  name: str,
456
- resolver_addr: Optional[ChecksumAddress] = None,
454
+ resolver_addr: ChecksumAddress | None = None,
457
455
  transact: Optional["TxParams"] = None,
458
456
  ) -> "Contract":
459
457
  if not transact:
@@ -468,7 +466,7 @@ class ENS(BaseENS):
468
466
 
469
467
  def _resolve(
470
468
  self, name: str, fn_name: str = "addr"
471
- ) -> Optional[Union[ChecksumAddress, str]]:
469
+ ) -> ChecksumAddress | str | None:
472
470
  normal_name = normalize_name(name)
473
471
  resolver, current_name = self._get_resolver(normal_name, fn_name)
474
472
  if not resolver:
@@ -501,7 +499,7 @@ class ENS(BaseENS):
501
499
  self,
502
500
  account: ChecksumAddress,
503
501
  name: str,
504
- parent_owned: Optional[str] = None,
502
+ parent_owned: str | None = None,
505
503
  ) -> None:
506
504
  if not address_in(account, self.w3.eth.accounts):
507
505
  raise UnauthorizedError(
@@ -511,7 +509,7 @@ class ENS(BaseENS):
511
509
 
512
510
  def _first_owner(
513
511
  self, name: str
514
- ) -> Tuple[Optional[ChecksumAddress], Sequence[str], str]:
512
+ ) -> tuple[ChecksumAddress | None, Sequence[str], str]:
515
513
  """
516
514
  Takes a name, and returns the owner of the deepest subdomain that has an owner
517
515
 
@@ -532,7 +530,7 @@ class ENS(BaseENS):
532
530
  owner: ChecksumAddress,
533
531
  unowned: Sequence[str],
534
532
  owned: str,
535
- old_owner: Optional[ChecksumAddress] = None,
533
+ old_owner: ChecksumAddress | None = None,
536
534
  transact: Optional["TxParams"] = None,
537
535
  ) -> None:
538
536
  if not transact:
@@ -549,7 +547,7 @@ class ENS(BaseENS):
549
547
 
550
548
  def _setup_reverse(
551
549
  self,
552
- name: Optional[str],
550
+ name: str | None,
553
551
  address: ChecksumAddress,
554
552
  transact: Optional["TxParams"] = None,
555
553
  ) -> HexBytes:
ens/utils.py CHANGED
@@ -6,11 +6,7 @@ from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
8
  Collection,
9
- Optional,
10
9
  Sequence,
11
- Tuple,
12
- Type,
13
- Union,
14
10
  cast,
15
11
  )
16
12
  import warnings
@@ -66,7 +62,7 @@ if TYPE_CHECKING:
66
62
  )
67
63
 
68
64
 
69
- def Web3() -> Type["_Web3"]:
65
+ def Web3() -> type["_Web3"]:
70
66
  from web3 import (
71
67
  Web3 as Web3Main,
72
68
  )
@@ -76,7 +72,7 @@ def Web3() -> Type["_Web3"]:
76
72
 
77
73
  def init_web3(
78
74
  provider: "BaseProvider" = None,
79
- middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
75
+ middleware: Sequence[tuple["Middleware", str]] | None = None,
80
76
  ) -> "_Web3":
81
77
  from web3 import (
82
78
  Web3 as Web3Main,
@@ -195,11 +191,11 @@ def is_valid_name(name: str) -> bool:
195
191
  return False
196
192
 
197
193
 
198
- def to_utc_datetime(timestamp: float) -> Optional[datetime]:
194
+ def to_utc_datetime(timestamp: float) -> datetime | None:
199
195
  return datetime.fromtimestamp(timestamp, timezone.utc) if timestamp else None
200
196
 
201
197
 
202
- def sha3_text(val: Union[str, bytes]) -> HexBytes:
198
+ def sha3_text(val: str | bytes) -> HexBytes:
203
199
  if isinstance(val, str):
204
200
  val = val.encode("utf-8")
205
201
  return Web3().keccak(val)
@@ -278,7 +274,7 @@ def assert_signer_in_modifier_kwargs(modifier_kwargs: Any) -> ChecksumAddress:
278
274
  return modifier_dict["from"]
279
275
 
280
276
 
281
- def is_none_or_zero_address(addr: Union[Address, ChecksumAddress, HexAddress]) -> bool:
277
+ def is_none_or_zero_address(addr: Address | ChecksumAddress | HexAddress) -> bool:
282
278
  return not addr or addr == EMPTY_ADDR_HEX
283
279
 
284
280
 
@@ -301,7 +297,7 @@ def is_valid_ens_name(ens_name: str) -> bool:
301
297
 
302
298
  def init_async_web3(
303
299
  provider: "AsyncBaseProvider" = None,
304
- middleware: Optional[Sequence[Tuple["Middleware", str]]] = (),
300
+ middleware: Sequence[tuple["Middleware", str]] | None = (),
305
301
  ) -> "AsyncWeb3[Any]":
306
302
  from web3 import (
307
303
  AsyncWeb3 as AsyncWeb3Main,
web3/__init__.py CHANGED
@@ -32,9 +32,6 @@ from web3.providers.rpc import ( # noqa: E402
32
32
  AsyncHTTPProvider,
33
33
  HTTPProvider,
34
34
  )
35
- from web3.providers.legacy_websocket import ( # noqa: E402
36
- LegacyWebSocketProvider,
37
- )
38
35
 
39
36
 
40
37
  __all__ = [
@@ -54,7 +51,6 @@ __all__ = [
54
51
  "HTTPProvider",
55
52
  "IPCProvider",
56
53
  "JSONBaseProvider",
57
- "LegacyWebSocketProvider",
58
54
  "PersistentConnection",
59
55
  "PersistentConnectionProvider",
60
56
  "WebSocketProvider",