faster-eth-utils 5.3.13__tar.gz → 5.3.17__tar.gz

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 (83) hide show
  1. {faster_eth_utils-5.3.13/faster_eth_utils.egg-info → faster_eth_utils-5.3.17}/PKG-INFO +23 -13
  2. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/applicators.py +23 -9
  3. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/curried/__init__.py +53 -47
  4. faster_eth_utils-5.3.17/faster_eth_utils/decorators.py +119 -0
  5. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/logging.py +23 -22
  6. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/types.py +2 -2
  7. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17/faster_eth_utils.egg-info}/PKG-INFO +23 -13
  8. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils.egg-info/requires.txt +19 -9
  9. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/pyproject.toml +8 -7
  10. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/setup.py +28 -25
  11. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/curried-utils/test_curried.py +11 -0
  12. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/functional-utils/test_type_inference.py +5 -0
  13. faster_eth_utils-5.3.13/faster_eth_utils/decorators.py +0 -79
  14. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/LICENSE +0 -0
  15. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/MANIFEST.in +0 -0
  16. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/README.md +0 -0
  17. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/__init__.py +0 -0
  18. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/__json/eth_networks.json +0 -0
  19. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/__main__.py +0 -0
  20. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/abi.py +0 -0
  21. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/address.py +0 -0
  22. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/conversions.py +0 -0
  23. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/crypto.py +0 -0
  24. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/currency.py +0 -0
  25. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/debug.py +0 -0
  26. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/encoding.py +0 -0
  27. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/exceptions.py +0 -0
  28. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/functional.py +0 -0
  29. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/hexadecimal.py +0 -0
  30. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/humanize.py +0 -0
  31. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/module_loading.py +0 -0
  32. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/network.py +0 -0
  33. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/numeric.py +0 -0
  34. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/py.typed +0 -0
  35. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/pydantic.py +0 -0
  36. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/toolz.py +0 -0
  37. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/typing/__init__.py +0 -0
  38. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/typing/misc.py +0 -0
  39. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils/units.py +0 -0
  40. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils.egg-info/SOURCES.txt +0 -0
  41. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils.egg-info/dependency_links.txt +0 -0
  42. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils.egg-info/not-zip-safe +0 -0
  43. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/faster_eth_utils.egg-info/top_level.txt +0 -0
  44. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/scripts/benchmark/compare_benchmark_results.py +0 -0
  45. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/scripts/benchmark/generate_benchmark_markdown.py +0 -0
  46. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/scripts/benchmark/parse_benchmark_output.py +0 -0
  47. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/scripts/release/test_package.py +0 -0
  48. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/setup.cfg +0 -0
  49. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/abi-utils/test_abi_utils.py +0 -0
  50. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/address-utils/test_address_utils.py +0 -0
  51. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/applicator-utils/test_applicators.py +0 -0
  52. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/conversion-utils/test_conversions.py +0 -0
  53. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/currency-utils/test_currency_tools.py +0 -0
  54. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/currency-utils/test_denoms_obj.py +0 -0
  55. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/decorator-utils/test_combomethod.py +0 -0
  56. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/decorator-utils/test_replace_exceptions.py +0 -0
  57. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/encoding-utils/test_big_endian_integer.py +0 -0
  58. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/functional-utils/test_return_value_decorators.py +0 -0
  59. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/hexadecimal-utils/test_0x_prefix_addition_and_removal.py +0 -0
  60. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/hexadecimal-utils/test_is_0x_prefixed.py +0 -0
  61. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/hexadecimal-utils/test_is_hex.py +0 -0
  62. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/hexadecimal-utils/test_is_hexstr.py +0 -0
  63. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_bytes.py +0 -0
  64. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_hash.py +0 -0
  65. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_hexstr.py +0 -0
  66. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_integer_sequence.py +0 -0
  67. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_ipfs_uri.py +0 -0
  68. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_seconds.py +0 -0
  69. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/humanize-utils/test_humanize_wei.py +0 -0
  70. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/logging-utils/test_DEBUG2_logging.py +0 -0
  71. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/logging-utils/test_compat_with_abc_ABC.py +0 -0
  72. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/logging-utils/test_get_logger.py +0 -0
  73. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/logging-utils/test_has_logger_metaclass.py +0 -0
  74. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/module-loading-utils/test_import_string.py +0 -0
  75. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/network-utils/test_network_utils.py +0 -0
  76. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/numeric-utils/test_clamp.py +0 -0
  77. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/pydantic-utils/test_camel_model.py +0 -0
  78. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/test_import_and_version.py +0 -0
  79. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/type-checks/mypy_typing_of_curried_utils.py +0 -0
  80. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/type-checks/mypy_typing_of_functional_utils.py +0 -0
  81. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/type-checks/mypy_typing_of_has_logger.py +0 -0
  82. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/core/types-utils/test_types_utils.py +0 -0
  83. {faster_eth_utils-5.3.13 → faster_eth_utils-5.3.17}/tests/mypy/abi_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster-eth-utils
3
- Version: 5.3.13
3
+ Version: 5.3.17
4
4
  Summary: A fork of eth-utils: Common utility functions for python code that interacts with Ethereum, implemented in C
5
5
  Home-page: https://github.com/BobTheBuidler/faster-eth-utils
6
6
  Author: The Ethereum Foundation
@@ -9,11 +9,13 @@ License: MIT
9
9
  Project-URL: Documentation, https://eth-utils.readthedocs.io/en/stable/
10
10
  Project-URL: Release Notes, https://github.com/BobTheBuidler/faster-eth-utils/releases
11
11
  Project-URL: Issues, https://github.com/BobTheBuidler/faster-eth-utils/issues
12
- Project-URL: Source, https://github.com/BobTheBuidler/faster-eth-utils
12
+ Project-URL: Source - Precompiled (.py), https://github.com/BobTheBuidler/faster-eth-utils/tree/master/faster_eth_utils
13
+ Project-URL: Source - Compiled (.c), https://github.com/BobTheBuidler/faster-eth-utils/tree/master/build
14
+ Project-URL: Benchmarks, https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks
15
+ Project-URL: Benchmarks - Results, https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks/results
13
16
  Project-URL: Original, https://github.com/ethereum/eth-utils
14
17
  Keywords: ethereum
15
18
  Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: MIT License
17
19
  Classifier: Natural Language :: English
18
20
  Classifier: Programming Language :: Python :: 3
19
21
  Classifier: Programming Language :: Python :: 3.8
@@ -26,10 +28,10 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
26
28
  Requires-Python: >=3.8, <4
27
29
  Description-Content-Type: text/markdown
28
30
  License-File: LICENSE
29
- Requires-Dist: cchecksum>=0.0.3
31
+ Requires-Dist: cchecksum==0.3.4
30
32
  Requires-Dist: eth-hash>=0.3.1
31
- Requires-Dist: eth-typing>=5.0.0
32
- Requires-Dist: eth-utils<6,>=5.2.0
33
+ Requires-Dist: eth-typing==5.2.1
34
+ Requires-Dist: eth-utils==5.3.1
33
35
  Requires-Dist: toolz>0.8.2; implementation_name == "pypy"
34
36
  Requires-Dist: cytoolz>=0.10.1; implementation_name == "cpython"
35
37
  Requires-Dist: pydantic<3,>=2.0.0
@@ -38,7 +40,7 @@ Requires-Dist: build>=0.9.0; extra == "dev"
38
40
  Requires-Dist: bump_my_version>=0.19.0; extra == "dev"
39
41
  Requires-Dist: eth-hash[pycryptodome]; extra == "dev"
40
42
  Requires-Dist: ipython; extra == "dev"
41
- Requires-Dist: mypy==1.18.2; extra == "dev"
43
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "dev"
42
44
  Requires-Dist: pre-commit>=3.4.0; extra == "dev"
43
45
  Requires-Dist: tox>=4.0.0; extra == "dev"
44
46
  Requires-Dist: twine; extra == "dev"
@@ -48,10 +50,9 @@ Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "dev"
48
50
  Requires-Dist: sphinx_rtd_theme>=1.0.0; extra == "dev"
49
51
  Requires-Dist: towncrier<26,>=24; extra == "dev"
50
52
  Requires-Dist: hypothesis>=4.43.0; extra == "dev"
51
- Requires-Dist: mypy==1.18.2; extra == "dev"
52
- Requires-Dist: pytest>=7.0.0; extra == "dev"
53
- Requires-Dist: pytest-codspeed>=2.0.0; extra == "dev"
53
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "dev"
54
54
  Requires-Dist: pytest-xdist>=2.4.0; extra == "dev"
55
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
55
56
  Provides-Extra: docs
56
57
  Requires-Dist: sphinx>=6.0.0; extra == "docs"
57
58
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "docs"
@@ -59,10 +60,19 @@ Requires-Dist: sphinx_rtd_theme>=1.0.0; extra == "docs"
59
60
  Requires-Dist: towncrier<26,>=24; extra == "docs"
60
61
  Provides-Extra: test
61
62
  Requires-Dist: hypothesis>=4.43.0; extra == "test"
62
- Requires-Dist: mypy==1.18.2; extra == "test"
63
- Requires-Dist: pytest>=7.0.0; extra == "test"
64
- Requires-Dist: pytest-codspeed>=2.0.0; extra == "test"
63
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "test"
65
64
  Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
65
+ Requires-Dist: pytest>=7.0.0; extra == "test"
66
+ Provides-Extra: codspeed
67
+ Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "codspeed"
68
+ Requires-Dist: pytest-test-groups; extra == "codspeed"
69
+ Requires-Dist: pytest>=7.0.0; extra == "codspeed"
70
+ Provides-Extra: benchmark
71
+ Requires-Dist: eth-utils==5.3.1; extra == "benchmark"
72
+ Requires-Dist: pytest-benchmark==5.2.2; extra == "benchmark"
73
+ Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "benchmark"
74
+ Requires-Dist: pytest-test-groups; extra == "benchmark"
75
+ Requires-Dist: pytest>=7.0.0; extra == "benchmark"
66
76
  Dynamic: author
67
77
  Dynamic: author-email
68
78
  Dynamic: classifier
@@ -1,4 +1,6 @@
1
+ import sys
1
2
  from typing import (
3
+ TYPE_CHECKING,
2
4
  Any,
3
5
  Callable,
4
6
  Dict,
@@ -21,9 +23,6 @@ from typing_extensions import (
21
23
  from .decorators import (
22
24
  return_arg_type,
23
25
  )
24
- from .functional import (
25
- to_dict,
26
- )
27
26
  from .pydantic import (
28
27
  CamelModel,
29
28
  )
@@ -32,6 +31,13 @@ from .toolz import (
32
31
  curry,
33
32
  )
34
33
 
34
+ if TYPE_CHECKING:
35
+ if sys.version_info >= (3, 9):
36
+ from _typeshed import SupportsBool
37
+ # We have to sacrifice a little bit of specificity on dinosaur Python3.8
38
+ else:
39
+ SupportsBool = Any
40
+
35
41
  TArg = TypeVar("TArg")
36
42
  TReturn = TypeVar("TReturn")
37
43
  TOther = TypeVar("TOther")
@@ -41,7 +47,9 @@ Formatters = Callable[[List[Any]], List[Any]]
41
47
 
42
48
  @return_arg_type(2)
43
49
  def apply_formatter_at_index(
44
- formatter: Callable[[TArg], TReturn], at_index: int, value: Sequence[Union[TArg, TOther]]
50
+ formatter: Callable[[TArg], TReturn],
51
+ at_index: int,
52
+ value: Sequence[Union[TArg, TOther]],
45
53
  ) -> Generator[Union[TOther, TReturn], None, None]:
46
54
  try:
47
55
  item = value[at_index]
@@ -69,7 +77,7 @@ def combine_argument_formatters(*formatters: Callable[..., Any]) -> Formatters:
69
77
  )
70
78
 
71
79
  _formatter_at_index = curry(apply_formatter_at_index)
72
- return compose( # type: ignore
80
+ return compose( # type: ignore [no-any-return]
73
81
  *(
74
82
  _formatter_at_index(formatter, index)
75
83
  for index, formatter in enumerate(formatters)
@@ -100,14 +108,18 @@ def apply_formatters_to_sequence(
100
108
 
101
109
  @overload
102
110
  def apply_formatter_if(
103
- condition: Callable[[TArg], TypeGuard[TOther]], formatter: Callable[[TOther], TReturn], value: TArg
111
+ condition: Callable[[TArg], TypeGuard[TOther]],
112
+ formatter: Callable[[TOther], TReturn],
113
+ value: TArg,
104
114
  ) -> Union[TArg, TReturn]: ...
105
115
 
116
+
106
117
  @overload
107
118
  def apply_formatter_if(
108
119
  condition: Callable[[TArg], bool], formatter: Callable[[TArg], TReturn], value: TArg
109
120
  ) -> Union[TArg, TReturn]: ...
110
121
 
122
+
111
123
  def apply_formatter_if( # type: ignore [misc]
112
124
  condition: Union[Callable[[TArg], TypeGuard[TOther]], Callable[[TArg], bool]],
113
125
  formatter: Union[Callable[[TOther], TReturn], Callable[[TArg], TReturn]],
@@ -164,9 +176,11 @@ def apply_formatter_to_array(
164
176
 
165
177
 
166
178
  def apply_one_of_formatters(
167
- formatter_condition_pairs: Tuple[Tuple[Callable[[TArg], Any], Callable[[TArg], Any]], ...],
168
- value: Any,
169
- ) -> Any:
179
+ formatter_condition_pairs: Tuple[
180
+ Tuple[Callable[[TArg], "SupportsBool"], Callable[[TArg], TReturn]], ...
181
+ ],
182
+ value: TArg,
183
+ ) -> TReturn:
170
184
  for condition, formatter in formatter_condition_pairs:
171
185
  if condition(value):
172
186
  return formatter(value)
@@ -1,4 +1,6 @@
1
+ import sys
1
2
  from typing import (
3
+ TYPE_CHECKING,
2
4
  Any,
3
5
  Callable,
4
6
  Dict,
@@ -10,6 +12,7 @@ from typing import (
10
12
  Union,
11
13
  overload,
12
14
  )
15
+ from typing_extensions import TypeGuard
13
16
 
14
17
  from faster_eth_utils import (
15
18
  CamelModel,
@@ -118,41 +121,53 @@ from faster_eth_utils.toolz import (
118
121
  curry,
119
122
  )
120
123
 
124
+ if TYPE_CHECKING:
125
+ if sys.version_info >= (3, 9):
126
+ from _typeshed import SupportsBool
127
+ # We have to sacrifice a little bit of specificity on dinosaur Python3.8
128
+ else:
129
+ SupportsBool = Any
130
+
131
+
132
+ TArg = TypeVar("TArg")
133
+ TOther = TypeVar("TOther")
121
134
  TReturn = TypeVar("TReturn")
122
135
  TValue = TypeVar("TValue")
123
136
 
124
137
 
125
138
  @overload
126
139
  def apply_formatter_if(
127
- condition: Callable[..., bool],
128
- ) -> Callable[[Callable[..., TReturn]], Callable[[TValue], Union[TReturn, TValue]]]:
129
- pass
130
-
140
+ condition: Callable[[TArg], TypeGuard[TOther]],
141
+ ) -> Callable[[Callable[[TOther], TReturn]], Callable[[TArg], Union[TReturn, TArg]]]:
142
+ ...
131
143
 
132
144
  @overload
133
145
  def apply_formatter_if(
134
- condition: Callable[..., bool], formatter: Callable[..., TReturn]
135
- ) -> Callable[[TValue], Union[TReturn, TValue]]:
136
- pass
137
-
146
+ condition: Callable[[TArg], TypeGuard[TOther]], formatter: Callable[[TOther], TReturn]
147
+ ) -> Callable[[TArg], Union[TReturn, TArg]]:
148
+ ...
138
149
 
139
150
  @overload
140
151
  def apply_formatter_if(
141
- condition: Callable[..., bool], formatter: Callable[..., TReturn], value: TValue
142
- ) -> Union[TReturn, TValue]:
143
- pass
152
+ condition: Callable[[TArg], TypeGuard[TOther]], formatter: Callable[[TOther], TReturn], value: TArg
153
+ ) -> Union[TReturn, TArg]:
154
+ ...
144
155
 
156
+ @overload
157
+ def apply_formatter_if(
158
+ condition: Callable[[TArg], bool], formatter: Callable[[TArg], TReturn], value: TArg
159
+ ) -> Union[TReturn, TArg]:
160
+ ...
145
161
 
146
- # This is just a stub to appease mypy, it gets overwritten later
147
162
  def apply_formatter_if( # type: ignore
148
- condition: Callable[..., bool],
149
- formatter: Optional[Callable[..., TReturn]] = None,
150
- value: Optional[TValue] = None,
163
+ condition: Union[Callable[[TArg], TypeGuard[TOther]], Callable[[TArg], bool]],
164
+ formatter: Optional[Union[Callable[[TOther], TReturn], Callable[[TArg], TReturn]]] = None,
165
+ value: Optional[TArg] = None,
151
166
  ) -> Union[
152
- Callable[[Callable[..., TReturn]], Callable[[TValue], Union[TReturn, TValue]]],
153
- Callable[[TValue], Union[TReturn, TValue]],
167
+ Callable[[Callable[[TOther], TReturn]], Callable[[TArg], Union[TReturn, TArg]]],
168
+ Callable[[TArg], Union[TReturn, TArg]],
154
169
  TReturn,
155
- TValue,
170
+ TArg,
156
171
  ]:
157
172
  pass
158
173
 
@@ -160,96 +175,86 @@ def apply_formatter_if( # type: ignore
160
175
  @overload
161
176
  def apply_one_of_formatters(
162
177
  formatter_condition_pairs: Sequence[
163
- Tuple[Callable[..., bool], Callable[..., TReturn]]
178
+ Tuple[Callable[[TArg], "SupportsBool"], Callable[[TArg], TReturn]]
164
179
  ],
165
- ) -> Callable[[TValue], TReturn]:
166
- ...
180
+ ) -> Callable[[TArg], TReturn]: ...
167
181
 
168
182
 
169
183
  @overload
170
184
  def apply_one_of_formatters(
171
185
  formatter_condition_pairs: Sequence[
172
- Tuple[Callable[..., bool], Callable[..., TReturn]]
186
+ Tuple[Callable[[TArg], "SupportsBool"], Callable[[TArg], TReturn]]
173
187
  ],
174
- value: TValue,
175
- ) -> TReturn:
176
- ...
188
+ value: TArg,
189
+ ) -> TReturn: ...
177
190
 
178
191
 
179
192
  # This is just a stub to appease mypy, it gets overwritten later
180
- def apply_one_of_formatters( # type: ignore
193
+ def apply_one_of_formatters(
181
194
  formatter_condition_pairs: Sequence[
182
- Tuple[Callable[..., bool], Callable[..., TReturn]]
195
+ Tuple[Callable[[TArg], "SupportsBool"], Callable[[TArg], TReturn]]
183
196
  ],
184
- value: Optional[TValue] = None,
185
- ) -> TReturn:
186
- ...
197
+ value: Optional[TArg] = None,
198
+ ) -> TReturn: ...
187
199
 
188
200
 
189
201
  @overload
190
202
  def hexstr_if_str(
191
203
  to_type: Callable[..., TReturn],
192
- ) -> Callable[[Union[bytes, int, str]], TReturn]:
193
- ...
204
+ ) -> Callable[[Union[bytes, int, str]], TReturn]: ...
194
205
 
195
206
 
196
207
  @overload
197
208
  def hexstr_if_str(
198
209
  to_type: Callable[..., TReturn], to_format: Union[bytes, int, str]
199
- ) -> TReturn:
200
- ...
210
+ ) -> TReturn: ...
201
211
 
202
212
 
203
213
  # This is just a stub to appease mypy, it gets overwritten later
204
214
  def hexstr_if_str( # type: ignore
205
215
  to_type: Callable[..., TReturn], to_format: Optional[Union[bytes, int, str]] = None
206
- ) -> TReturn:
207
- ...
216
+ ) -> TReturn: ...
208
217
 
209
218
 
210
219
  @overload
211
220
  def text_if_str(
212
221
  to_type: Callable[..., TReturn],
213
- ) -> Callable[[Union[bytes, int, str]], TReturn]:
214
- ...
222
+ ) -> Callable[[Union[bytes, int, str]], TReturn]: ...
215
223
 
216
224
 
217
225
  @overload
218
226
  def text_if_str(
219
227
  to_type: Callable[..., TReturn], text_or_primitive: Union[bytes, int, str]
220
- ) -> TReturn:
221
- ...
228
+ ) -> TReturn: ...
222
229
 
223
230
 
224
231
  # This is just a stub to appease mypy, it gets overwritten later
225
232
  def text_if_str( # type: ignore
226
233
  to_type: Callable[..., TReturn],
227
234
  text_or_primitive: Optional[Union[bytes, int, str]] = None,
228
- ) -> TReturn:
229
- ...
235
+ ) -> TReturn: ...
230
236
 
231
237
 
232
238
  @overload
233
239
  def apply_formatters_to_dict(
234
240
  formatters: Dict[Any, Any], unaliased: bool = False
235
- ) -> Callable[[Dict[Any, Any]], TReturn]:
241
+ ) -> Callable[[Union[Dict[Any, Any], CamelModel]], Dict[Any, Any]]:
236
242
  ...
237
243
 
238
244
 
239
245
  @overload
240
246
  def apply_formatters_to_dict(
241
- formatters: Dict[Any, Any], value: Union[Dict[Any, Any], CamelModel]
247
+ formatters: Dict[Any, Any], value: Union[Dict[Any, Any], CamelModel], unaliased: bool = False
242
248
  ) -> Dict[Any, Any]:
243
249
  ...
244
250
 
245
251
 
246
252
  # This is just a stub to appease mypy, it gets overwritten later
247
- def apply_formatters_to_dict( # type: ignore
253
+ def apply_formatters_to_dict(
248
254
  formatters: Dict[Any, Any],
249
255
  value: Optional[Union[Dict[Any, Any], CamelModel]] = None,
250
256
  unaliased: bool = False,
251
- ) -> Dict[Any, Any]:
252
- ...
257
+ ) -> Dict[Any, Any]: ...
253
258
 
254
259
 
255
260
  apply_formatter_at_index = curry(apply_formatter_at_index)
@@ -289,6 +294,7 @@ del Sequence
289
294
  del TReturn
290
295
  del TValue
291
296
  del Tuple
297
+ del TypeGuard
292
298
  del TypeVar
293
299
  del Union
294
300
  del curry
@@ -0,0 +1,119 @@
1
+ import functools
2
+ from typing import (
3
+ Any,
4
+ Callable,
5
+ Dict,
6
+ Final,
7
+ Generic,
8
+ Optional,
9
+ Tuple,
10
+ Type,
11
+ TypeVar,
12
+ Union,
13
+ final,
14
+ )
15
+
16
+ from typing_extensions import Concatenate, ParamSpec
17
+
18
+ P = ParamSpec("P")
19
+
20
+ T = TypeVar("T")
21
+
22
+ TInstance = TypeVar("TInstance", bound=object)
23
+ """A TypeVar representing an instance that a method can bind to."""
24
+
25
+
26
+ @final
27
+ class combomethod(Generic[TInstance, P, T]):
28
+ def __init__(
29
+ self, method: Callable[Concatenate[Union[TInstance, Type[TInstance]], P], T]
30
+ ) -> None:
31
+ self.method: Final = method
32
+
33
+ def __repr__(self) -> str:
34
+ return f"combomethod({self.method})"
35
+
36
+ def __get__(
37
+ self,
38
+ obj: Optional[TInstance],
39
+ objtype: Type[TInstance],
40
+ ) -> Callable[P, T]:
41
+
42
+ @functools.wraps(self.method)
43
+ def _wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
44
+ if obj is not None:
45
+ return self.method(obj, *args, **kwargs)
46
+ else:
47
+ return self.method(objtype, *args, **kwargs) # type: ignore [arg-type]
48
+
49
+ return _wrapper
50
+
51
+
52
+ _return_arg_type_deco_cache: Final[
53
+ Dict[int, Callable[[Callable[P, T]], Callable[P, Any]]]
54
+ ] = {}
55
+ # No need to hold so many unique instances in memory
56
+
57
+
58
+ def return_arg_type(at_position: int) -> Callable[[Callable[P, T]], Callable[P, Any]]:
59
+ """
60
+ Wrap the return value with the result of `type(args[at_position])`.
61
+ """
62
+ if deco := _return_arg_type_deco_cache.get(at_position):
63
+ return deco
64
+
65
+ def decorator(to_wrap: Callable[P, Any]) -> Callable[P, Any]:
66
+ @functools.wraps(to_wrap)
67
+ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Any:
68
+ result = to_wrap(*args, **kwargs)
69
+ ReturnType = type(args[at_position])
70
+ return ReturnType(result) # type: ignore [call-arg]
71
+
72
+ return wrapper
73
+
74
+ _return_arg_type_deco_cache[at_position] = decorator
75
+
76
+ return decorator
77
+
78
+
79
+ ExcType = Type[BaseException]
80
+
81
+ ReplaceExceptionsCache = Dict[
82
+ Tuple[Tuple[ExcType, ExcType], ...],
83
+ Callable[[Callable[P, T]], Callable[P, T]],
84
+ ]
85
+
86
+ _replace_exceptions_deco_cache: Final[ReplaceExceptionsCache[..., Any]] = {}
87
+ # No need to hold so many unique instances in memory
88
+
89
+
90
+ def replace_exceptions(
91
+ old_to_new_exceptions: Dict[ExcType, ExcType],
92
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]:
93
+ """
94
+ Replaces old exceptions with new exceptions to be raised in their place.
95
+ """
96
+ cache_key = tuple(old_to_new_exceptions.items())
97
+ if deco := _replace_exceptions_deco_cache.get(cache_key):
98
+ return deco
99
+
100
+ old_exceptions = tuple(old_to_new_exceptions)
101
+
102
+ def decorator(to_wrap: Callable[P, T]) -> Callable[P, T]:
103
+ @functools.wraps(to_wrap)
104
+ def wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
105
+ try:
106
+ return to_wrap(*args, **kwargs)
107
+ except old_exceptions as err:
108
+ try:
109
+ raise old_to_new_exceptions[type(err)](err) from err
110
+ except KeyError:
111
+ raise TypeError(
112
+ f"could not look up new exception to use for {repr(err)}"
113
+ ) from err
114
+
115
+ return wrapped
116
+
117
+ _replace_exceptions_deco_cache[cache_key] = decorator
118
+
119
+ return decorator
@@ -12,6 +12,7 @@ from typing import (
12
12
  TypeVar,
13
13
  Union,
14
14
  cast,
15
+ overload,
15
16
  )
16
17
 
17
18
  from .toolz import (
@@ -53,8 +54,7 @@ def setup_DEBUG2_logging() -> None:
53
54
  """
54
55
  if not hasattr(logging, "DEBUG2"):
55
56
  logging.addLevelName(DEBUG2_LEVEL_NUM, "DEBUG2")
56
- logging.DEBUG2 = DEBUG2_LEVEL_NUM # type: ignore
57
-
57
+ logging.DEBUG2 = DEBUG2_LEVEL_NUM # type: ignore [attr-defined]
58
58
 
59
59
  @contextlib.contextmanager
60
60
  def _use_logger_class(logger_class: Type[logging.Logger]) -> Iterator[None]:
@@ -66,24 +66,26 @@ def _use_logger_class(logger_class: Type[logging.Logger]) -> Iterator[None]:
66
66
  logging.setLoggerClass(original_logger_class)
67
67
 
68
68
 
69
- def get_logger(name: str, logger_class: Union[Type[TLogger], None] = None) -> TLogger:
69
+ @overload
70
+ def get_logger(name: str, logger_class: Type[TLogger]) -> TLogger: ...
71
+ @overload
72
+ def get_logger(name: str, logger_class: None = None) -> logging.Logger: ...
73
+ def get_logger(name: str, logger_class: Union[Type[TLogger], None] = None) -> Union[TLogger, logging.Logger]:
70
74
  if logger_class is None:
75
+ return logging.getLogger(name)
76
+
77
+ with _use_logger_class(logger_class):
78
+ # The logging module caches logger instances. The following code
79
+ # ensures that if there is a cached instance that we don't
80
+ # accidentally return the incorrect logger type because the logging
81
+ # module does not *update* the cached instance in the event that
82
+ # the global logging class changes.
83
+ manager = logging.Logger.manager
84
+ logger_dict = manager.loggerDict
85
+ cached_logger = logger_dict.get(name)
86
+ if cached_logger is not None and type(cached_logger) is not logger_class:
87
+ del logger_dict[name]
71
88
  return cast(TLogger, logging.getLogger(name))
72
- else:
73
- with _use_logger_class(logger_class):
74
- # The logging module caches logger instances. The following code
75
- # ensures that if there is a cached instance that we don't
76
- # accidentally return the incorrect logger type because the logging
77
- # module does not *update* the cached instance in the event that
78
- # the global logging class changes.
79
- #
80
- # types ignored b/c mypy doesn't identify presence of
81
- # manager on logging.Logger
82
- manager = logging.Logger.manager
83
- if name in manager.loggerDict:
84
- if type(manager.loggerDict[name]) is not logger_class:
85
- del manager.loggerDict[name]
86
- return cast(TLogger, logging.getLogger(name))
87
89
 
88
90
 
89
91
  def get_extended_debug_logger(name: str) -> ExtendedDebugLogger:
@@ -115,9 +117,8 @@ class HasLoggerMeta(type):
115
117
  return super().__new__(mcls, name, bases, namespace)
116
118
  if "__qualname__" not in namespace:
117
119
  raise AttributeError("Missing __qualname__")
118
-
119
- with _use_logger_class(mcls.logger_class):
120
- logger = logging.getLogger(namespace["__qualname__"])
120
+
121
+ logger = get_logger(namespace["__qualname__"], mcls.logger_class)
121
122
 
122
123
  return super().__new__(mcls, name, bases, assoc(namespace, "logger", logger))
123
124
 
@@ -141,5 +142,5 @@ class HasLogger(metaclass=HasLoggerMeta):
141
142
  HasExtendedDebugLoggerMeta = HasLoggerMeta.replace_logger_class(ExtendedDebugLogger)
142
143
 
143
144
 
144
- class HasExtendedDebugLogger(metaclass=HasExtendedDebugLoggerMeta): # type: ignore
145
+ class HasExtendedDebugLogger(metaclass=HasExtendedDebugLoggerMeta): # type: ignore [metaclass,misc]
145
146
  logger: ExtendedDebugLogger
@@ -45,11 +45,11 @@ def is_boolean(value: Any) -> TypeGuard[bool]:
45
45
 
46
46
 
47
47
  def is_dict(obj: Any) -> TypeGuard[collections.abc.Mapping[Any, Any]]:
48
- return isinstance(obj, Mapping)
48
+ return isinstance(obj, dict) or isinstance(obj, Mapping)
49
49
 
50
50
 
51
51
  def is_list_like(obj: Any) -> TypeGuard[collections.abc.Sequence[Any]]:
52
- return not is_string(obj) and isinstance(obj, Sequence)
52
+ return isinstance(obj, (list, tuple)) or not is_string(obj) and isinstance(obj, Sequence)
53
53
 
54
54
 
55
55
  def is_list(obj: Any) -> TypeGuard[List[Any]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster-eth-utils
3
- Version: 5.3.13
3
+ Version: 5.3.17
4
4
  Summary: A fork of eth-utils: Common utility functions for python code that interacts with Ethereum, implemented in C
5
5
  Home-page: https://github.com/BobTheBuidler/faster-eth-utils
6
6
  Author: The Ethereum Foundation
@@ -9,11 +9,13 @@ License: MIT
9
9
  Project-URL: Documentation, https://eth-utils.readthedocs.io/en/stable/
10
10
  Project-URL: Release Notes, https://github.com/BobTheBuidler/faster-eth-utils/releases
11
11
  Project-URL: Issues, https://github.com/BobTheBuidler/faster-eth-utils/issues
12
- Project-URL: Source, https://github.com/BobTheBuidler/faster-eth-utils
12
+ Project-URL: Source - Precompiled (.py), https://github.com/BobTheBuidler/faster-eth-utils/tree/master/faster_eth_utils
13
+ Project-URL: Source - Compiled (.c), https://github.com/BobTheBuidler/faster-eth-utils/tree/master/build
14
+ Project-URL: Benchmarks, https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks
15
+ Project-URL: Benchmarks - Results, https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks/results
13
16
  Project-URL: Original, https://github.com/ethereum/eth-utils
14
17
  Keywords: ethereum
15
18
  Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: MIT License
17
19
  Classifier: Natural Language :: English
18
20
  Classifier: Programming Language :: Python :: 3
19
21
  Classifier: Programming Language :: Python :: 3.8
@@ -26,10 +28,10 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
26
28
  Requires-Python: >=3.8, <4
27
29
  Description-Content-Type: text/markdown
28
30
  License-File: LICENSE
29
- Requires-Dist: cchecksum>=0.0.3
31
+ Requires-Dist: cchecksum==0.3.4
30
32
  Requires-Dist: eth-hash>=0.3.1
31
- Requires-Dist: eth-typing>=5.0.0
32
- Requires-Dist: eth-utils<6,>=5.2.0
33
+ Requires-Dist: eth-typing==5.2.1
34
+ Requires-Dist: eth-utils==5.3.1
33
35
  Requires-Dist: toolz>0.8.2; implementation_name == "pypy"
34
36
  Requires-Dist: cytoolz>=0.10.1; implementation_name == "cpython"
35
37
  Requires-Dist: pydantic<3,>=2.0.0
@@ -38,7 +40,7 @@ Requires-Dist: build>=0.9.0; extra == "dev"
38
40
  Requires-Dist: bump_my_version>=0.19.0; extra == "dev"
39
41
  Requires-Dist: eth-hash[pycryptodome]; extra == "dev"
40
42
  Requires-Dist: ipython; extra == "dev"
41
- Requires-Dist: mypy==1.18.2; extra == "dev"
43
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "dev"
42
44
  Requires-Dist: pre-commit>=3.4.0; extra == "dev"
43
45
  Requires-Dist: tox>=4.0.0; extra == "dev"
44
46
  Requires-Dist: twine; extra == "dev"
@@ -48,10 +50,9 @@ Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "dev"
48
50
  Requires-Dist: sphinx_rtd_theme>=1.0.0; extra == "dev"
49
51
  Requires-Dist: towncrier<26,>=24; extra == "dev"
50
52
  Requires-Dist: hypothesis>=4.43.0; extra == "dev"
51
- Requires-Dist: mypy==1.18.2; extra == "dev"
52
- Requires-Dist: pytest>=7.0.0; extra == "dev"
53
- Requires-Dist: pytest-codspeed>=2.0.0; extra == "dev"
53
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "dev"
54
54
  Requires-Dist: pytest-xdist>=2.4.0; extra == "dev"
55
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
55
56
  Provides-Extra: docs
56
57
  Requires-Dist: sphinx>=6.0.0; extra == "docs"
57
58
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "docs"
@@ -59,10 +60,19 @@ Requires-Dist: sphinx_rtd_theme>=1.0.0; extra == "docs"
59
60
  Requires-Dist: towncrier<26,>=24; extra == "docs"
60
61
  Provides-Extra: test
61
62
  Requires-Dist: hypothesis>=4.43.0; extra == "test"
62
- Requires-Dist: mypy==1.18.2; extra == "test"
63
- Requires-Dist: pytest>=7.0.0; extra == "test"
64
- Requires-Dist: pytest-codspeed>=2.0.0; extra == "test"
63
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "test"
65
64
  Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
65
+ Requires-Dist: pytest>=7.0.0; extra == "test"
66
+ Provides-Extra: codspeed
67
+ Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "codspeed"
68
+ Requires-Dist: pytest-test-groups; extra == "codspeed"
69
+ Requires-Dist: pytest>=7.0.0; extra == "codspeed"
70
+ Provides-Extra: benchmark
71
+ Requires-Dist: eth-utils==5.3.1; extra == "benchmark"
72
+ Requires-Dist: pytest-benchmark==5.2.2; extra == "benchmark"
73
+ Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "benchmark"
74
+ Requires-Dist: pytest-test-groups; extra == "benchmark"
75
+ Requires-Dist: pytest>=7.0.0; extra == "benchmark"
66
76
  Dynamic: author
67
77
  Dynamic: author-email
68
78
  Dynamic: classifier
@@ -1,7 +1,7 @@
1
- cchecksum>=0.0.3
1
+ cchecksum==0.3.4
2
2
  eth-hash>=0.3.1
3
- eth-typing>=5.0.0
4
- eth-utils<6,>=5.2.0
3
+ eth-typing==5.2.1
4
+ eth-utils==5.3.1
5
5
  pydantic<3,>=2.0.0
6
6
 
7
7
  [:implementation_name == "cpython"]
@@ -10,12 +10,24 @@ cytoolz>=0.10.1
10
10
  [:implementation_name == "pypy"]
11
11
  toolz>0.8.2
12
12
 
13
+ [benchmark]
14
+ eth-utils==5.3.1
15
+ pytest-benchmark==5.2.2
16
+ pytest-codspeed<4.3,>=4.2
17
+ pytest-test-groups
18
+ pytest>=7.0.0
19
+
20
+ [codspeed]
21
+ pytest-codspeed<4.3,>=4.2
22
+ pytest-test-groups
23
+ pytest>=7.0.0
24
+
13
25
  [dev]
14
26
  build>=0.9.0
15
27
  bump_my_version>=0.19.0
16
28
  eth-hash[pycryptodome]
17
29
  ipython
18
- mypy==1.18.2
30
+ mypy<1.18.3,>=1.14.1
19
31
  pre-commit>=3.4.0
20
32
  tox>=4.0.0
21
33
  twine
@@ -25,9 +37,8 @@ sphinx-autobuild>=2021.3.14
25
37
  sphinx_rtd_theme>=1.0.0
26
38
  towncrier<26,>=24
27
39
  hypothesis>=4.43.0
28
- pytest>=7.0.0
29
- pytest-codspeed>=2.0.0
30
40
  pytest-xdist>=2.4.0
41
+ pytest>=7.0.0
31
42
 
32
43
  [docs]
33
44
  sphinx>=6.0.0
@@ -37,7 +48,6 @@ towncrier<26,>=24
37
48
 
38
49
  [test]
39
50
  hypothesis>=4.43.0
40
- mypy==1.18.2
41
- pytest>=7.0.0
42
- pytest-codspeed>=2.0.0
51
+ mypy<1.18.3,>=1.14.1
43
52
  pytest-xdist>=2.4.0
53
+ pytest>=7.0.0
@@ -2,13 +2,14 @@
2
2
  requires = [
3
3
  "setuptools",
4
4
  "wheel",
5
- "mypy[mypyc]>=1.14.1,<1.18.3",
6
- "cchecksum>=0.0.3",
7
- "eth-hash>=0.3.1",
8
- "eth-typing>=5.0.0",
9
- # puccinialin (installed with faster-eth-utils) is unable to install for
5
+ "mypy[mypyc]==1.14.1; python_version == '3.8'",
6
+ "mypy[mypyc]==1.18.2; python_version != '3.8'",
7
+ "cchecksum==0.3.4",
8
+ "eth-hash==0.7.1",
9
+ "eth-typing==5.2.1",
10
+ # puccinialin (installed with eth-utils) is unable to install for
10
11
  # Python3.14 on 32-bit manylinux or on 32-bit musllinux for any Python version
11
- "eth-utils>=5.2.0,<6; platform_system != 'Linux' or platform_machine != 'i686'",
12
+ "eth-utils==5.3.1; platform_system != 'Linux' or platform_machine != 'i686'",
12
13
  ]
13
14
  build-backend = "setuptools.build_meta"
14
15
 
@@ -139,7 +140,7 @@ name = "Removals"
139
140
  showcontent = true
140
141
 
141
142
  [tool.bumpversion]
142
- current_version = "5.3.13"
143
+ current_version = "5.3.17"
143
144
  parse = """
144
145
  (?P<major>\\d+)
145
146
  \\.(?P<minor>\\d+)
@@ -46,7 +46,6 @@ else:
46
46
  "--install-types",
47
47
  "--disable-error-code=attr-defined",
48
48
  "--disable-error-code=comparison-overlap",
49
- "--disable-error-code=typeddict-item",
50
49
  "--disable-error-code=no-any-return",
51
50
  "--disable-error-code=misc",
52
51
  "--disable-error-code=unused-ignore",
@@ -55,32 +54,33 @@ else:
55
54
  )
56
55
 
57
56
  MYPY_REQUIREMENT = f"mypy=={'1.14.1' if sys.version_info < (3, 9) else '1.18.2'}"
57
+ PYTEST_REQUIREMENT = "pytest>=7.0.0"
58
+
59
+
60
+ def read_requirements(path):
61
+ with open(path) as f:
62
+ reqs = set()
63
+ for line in f:
64
+ if stripped := line.strip():
65
+ if not stripped.startswith("#"):
66
+ if stripped.startswith("-r "):
67
+ reqs.update(read_requirements(stripped[3:]))
68
+ else:
69
+ reqs.add(stripped)
70
+ return sorted(reqs)
71
+
58
72
 
59
73
  extras_require = {
60
- "dev": [
61
- "build>=0.9.0",
62
- "bump_my_version>=0.19.0",
63
- "eth-hash[pycryptodome]",
64
- "ipython",
65
- MYPY_REQUIREMENT,
66
- "pre-commit>=3.4.0",
67
- "tox>=4.0.0",
68
- "twine",
69
- "wheel",
70
- ],
74
+ "dev": read_requirements("requirements-dev.txt"),
71
75
  "docs": [
72
76
  "sphinx>=6.0.0",
73
77
  "sphinx-autobuild>=2021.3.14",
74
78
  "sphinx_rtd_theme>=1.0.0",
75
79
  "towncrier>=24,<26",
76
80
  ],
77
- "test": [
78
- "hypothesis>=4.43.0",
79
- MYPY_REQUIREMENT,
80
- "pytest>=7.0.0",
81
- "pytest-codspeed>=2.0.0",
82
- "pytest-xdist>=2.4.0",
83
- ],
81
+ "test": read_requirements("requirements-test.txt"),
82
+ "codspeed": read_requirements("requirements-codspeed.txt"),
83
+ "benchmark": read_requirements("requirements-benchmark.txt"),
84
84
  }
85
85
 
86
86
  extras_require["dev"] = (
@@ -95,7 +95,7 @@ with open("./README.md") as readme:
95
95
  setup(
96
96
  name="faster-eth-utils",
97
97
  # *IMPORTANT*: Don't manually change the version here. Use `make bump`, as described in readme
98
- version="5.3.13",
98
+ version="5.3.17",
99
99
  description=(
100
100
  """A fork of eth-utils: Common utility functions for python code that interacts with Ethereum, implemented in C"""
101
101
  ),
@@ -108,15 +108,18 @@ setup(
108
108
  "Documentation": "https://eth-utils.readthedocs.io/en/stable/",
109
109
  "Release Notes": "https://github.com/BobTheBuidler/faster-eth-utils/releases",
110
110
  "Issues": "https://github.com/BobTheBuidler/faster-eth-utils/issues",
111
- "Source": "https://github.com/BobTheBuidler/faster-eth-utils",
111
+ "Source - Precompiled (.py)": "https://github.com/BobTheBuidler/faster-eth-utils/tree/master/faster_eth_utils",
112
+ "Source - Compiled (.c)": "https://github.com/BobTheBuidler/faster-eth-utils/tree/master/build",
113
+ "Benchmarks": "https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks",
114
+ "Benchmarks - Results": "https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks/results",
112
115
  "Original": "https://github.com/ethereum/eth-utils",
113
116
  },
114
117
  include_package_data=True,
115
118
  install_requires=[
116
- "cchecksum>=0.0.3",
119
+ "cchecksum==0.3.4",
117
120
  "eth-hash>=0.3.1",
118
- "eth-typing>=5.0.0",
119
- "eth-utils>=5.2.0,<6",
121
+ "eth-typing==5.2.1",
122
+ "eth-utils==5.3.1",
120
123
  "toolz>0.8.2;implementation_name=='pypy'",
121
124
  "cytoolz>=0.10.1;implementation_name=='cpython'",
122
125
  "pydantic>=2.0.0,<3",
@@ -125,6 +128,7 @@ setup(
125
128
  extras_require=extras_require,
126
129
  py_modules=["eth_utils"],
127
130
  license="MIT",
131
+ license_files=["LICENSE"],
128
132
  zip_safe=False,
129
133
  keywords="ethereum",
130
134
  packages=find_packages(exclude=["scripts", "scripts.*", "tests", "tests.*"]),
@@ -132,7 +136,6 @@ setup(
132
136
  package_data={"faster_eth_utils": ["py.typed"]},
133
137
  classifiers=[
134
138
  "Intended Audience :: Developers",
135
- "License :: OSI Approved :: MIT License",
136
139
  "Natural Language :: English",
137
140
  "Programming Language :: Python :: 3",
138
141
  "Programming Language :: Python :: 3.8",
@@ -1,3 +1,7 @@
1
+ import sys
2
+
3
+ import pytest
4
+
1
5
  try:
2
6
  from cytoolz import (
3
7
  curry,
@@ -33,6 +37,13 @@ def enhanced_has_keywords(func):
33
37
 
34
38
 
35
39
  # heavily inspired by https://github.com/pytoolz/toolz/blob/20d8aefc0a5/toolz/tests/test_curried.py # noqa: E501
40
+ @pytest.mark.skipif(
41
+ sys.version_info < (3, 9),
42
+ reason=(
43
+ "This test fails on 3.8 and I don't care to figure out why. "
44
+ "Feel free to make a PR if you need something that's missing."
45
+ ),
46
+ )
36
47
  def test_curried_namespace():
37
48
  def should_curry(value):
38
49
  if not callable(value) or isinstance(value, curry) or isinstance(value, type):
@@ -1,4 +1,5 @@
1
1
  import pytest
2
+ import sys
2
3
  from typing import (
3
4
  List,
4
5
  )
@@ -30,6 +31,10 @@ def check_mypy_run(
30
31
 
31
32
  # The following tests all run code snippets through mypy that contain a
32
33
  # `reveal_type` statement, and then match the mypy output against our expectations
34
+ @pytest.mark.skipif(
35
+ sys.platform.startswith("win"),
36
+ reason="This test's file path string matching doesn't work for Windows paths.",
37
+ )
33
38
  @pytest.mark.parametrize(
34
39
  "fixture,message",
35
40
  (
@@ -1,79 +0,0 @@
1
- import functools
2
- import itertools
3
- import os
4
- from typing import (
5
- Any,
6
- Callable,
7
- Dict,
8
- Optional,
9
- Type,
10
- TypeVar,
11
- final,
12
- )
13
-
14
- from .types import (
15
- is_text,
16
- )
17
-
18
- T = TypeVar("T")
19
-
20
-
21
- @final
22
- class combomethod:
23
- def __init__(self, method: Callable[..., Any]) -> None:
24
- self.method = method
25
-
26
- def __get__(
27
- self, obj: Optional[T] = None, objtype: Optional[Type[T]] = None
28
- ) -> Callable[..., Any]:
29
- @functools.wraps(self.method)
30
- def _wrapper(*args: Any, **kwargs: Any) -> Any:
31
- if obj is not None:
32
- return self.method(obj, *args, **kwargs)
33
- else:
34
- return self.method(objtype, *args, **kwargs)
35
-
36
- return _wrapper
37
-
38
-
39
- def return_arg_type(at_position: int) -> Callable[..., Callable[..., T]]:
40
- """
41
- Wrap the return value with the result of `type(args[at_position])`.
42
- """
43
-
44
- def decorator(to_wrap: Callable[..., Any]) -> Callable[..., T]:
45
- @functools.wraps(to_wrap)
46
- def wrapper(*args: Any, **kwargs: Any) -> T: # type: ignore
47
- result = to_wrap(*args, **kwargs)
48
- ReturnType = type(args[at_position])
49
- return ReturnType(result) # type: ignore
50
-
51
- return wrapper
52
-
53
- return decorator
54
-
55
-
56
- def replace_exceptions(
57
- old_to_new_exceptions: Dict[Type[BaseException], Type[BaseException]]
58
- ) -> Callable[[Callable[..., T]], Callable[..., T]]:
59
- """
60
- Replaces old exceptions with new exceptions to be raised in their place.
61
- """
62
- old_exceptions = tuple(old_to_new_exceptions.keys())
63
-
64
- def decorator(to_wrap: Callable[..., T]) -> Callable[..., T]:
65
- @functools.wraps(to_wrap)
66
- def wrapped(*args: Any, **kwargs: Any) -> T:
67
- try:
68
- return to_wrap(*args, **kwargs)
69
- except old_exceptions as err:
70
- try:
71
- raise old_to_new_exceptions[type(err)](err) from err
72
- except KeyError:
73
- raise TypeError(
74
- f"could not look up new exception to use for {repr(err)}"
75
- ) from err
76
-
77
- return wrapped
78
-
79
- return decorator