faster-eth-utils 2.3.1__cp311-cp311-win32.whl → 5.3.23__cp311-cp311-win32.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.
Potentially problematic release.
This version of faster-eth-utils might be problematic. Click here for more details.
- faster_eth_utils/__init__.py +54 -17
- faster_eth_utils/__json/eth_networks.json +1 -0
- faster_eth_utils/__main__.py +3 -1
- faster_eth_utils/abi.cp311-win32.pyd +0 -0
- faster_eth_utils/abi.py +840 -37
- faster_eth_utils/address.cp311-win32.pyd +0 -0
- faster_eth_utils/address.py +54 -66
- faster_eth_utils/applicators.cp311-win32.pyd +0 -0
- faster_eth_utils/applicators.py +126 -71
- faster_eth_utils/conversions.cp311-win32.pyd +0 -0
- faster_eth_utils/conversions.py +57 -30
- faster_eth_utils/crypto.cp311-win32.pyd +0 -0
- faster_eth_utils/crypto.py +11 -6
- faster_eth_utils/currency.cp311-win32.pyd +0 -0
- faster_eth_utils/currency.py +74 -33
- faster_eth_utils/curried/__init__.py +110 -89
- faster_eth_utils/debug.cp311-win32.pyd +0 -0
- faster_eth_utils/debug.py +3 -3
- faster_eth_utils/decorators.cp311-win32.pyd +0 -0
- faster_eth_utils/decorators.py +73 -24
- faster_eth_utils/encoding.cp311-win32.pyd +0 -0
- faster_eth_utils/encoding.py +1 -1
- faster_eth_utils/exceptions.cp311-win32.pyd +0 -0
- faster_eth_utils/exceptions.py +8 -3
- faster_eth_utils/functional.cp311-win32.pyd +0 -0
- faster_eth_utils/functional.py +42 -28
- faster_eth_utils/hexadecimal.cp311-win32.pyd +0 -0
- faster_eth_utils/hexadecimal.py +34 -26
- faster_eth_utils/humanize.cp311-win32.pyd +0 -0
- faster_eth_utils/humanize.py +55 -27
- faster_eth_utils/logging.py +65 -64
- faster_eth_utils/module_loading.cp311-win32.pyd +0 -0
- faster_eth_utils/module_loading.py +8 -7
- faster_eth_utils/network.cp311-win32.pyd +0 -0
- faster_eth_utils/network.py +25 -14
- faster_eth_utils/numeric.cp311-win32.pyd +0 -0
- faster_eth_utils/numeric.py +11 -4
- faster_eth_utils/pydantic.py +99 -0
- faster_eth_utils/toolz.cp311-win32.pyd +0 -0
- faster_eth_utils/toolz.py +82 -152
- faster_eth_utils/types.cp311-win32.pyd +0 -0
- faster_eth_utils/types.py +34 -21
- faster_eth_utils/typing/misc.py +3 -1
- faster_eth_utils/units.cp311-win32.pyd +0 -0
- faster_eth_utils-5.3.23.dist-info/METADATA +192 -0
- faster_eth_utils-5.3.23.dist-info/RECORD +53 -0
- {faster_eth_utils-2.3.1.dist-info → faster_eth_utils-5.3.23.dist-info}/licenses/LICENSE +1 -1
- faster_eth_utils-5.3.23.dist-info/top_level.txt +3 -0
- faster_eth_utils__mypyc.cp311-win32.pyd +0 -0
- bce0bfc64ce5e845ec4a__mypyc.cp311-win32.pyd +0 -0
- faster_eth_utils-2.3.1.dist-info/METADATA +0 -160
- faster_eth_utils-2.3.1.dist-info/RECORD +0 -45
- faster_eth_utils-2.3.1.dist-info/top_level.txt +0 -3
- {faster_eth_utils-2.3.1.dist-info → faster_eth_utils-5.3.23.dist-info}/WHEEL +0 -0
faster_eth_utils/network.py
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import (
|
|
2
|
+
dataclass,
|
|
3
|
+
)
|
|
2
4
|
import json
|
|
3
5
|
import os
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import (
|
|
8
|
+
Path,
|
|
9
|
+
)
|
|
10
|
+
from typing import (
|
|
11
|
+
Final,
|
|
12
|
+
)
|
|
6
13
|
|
|
7
|
-
from eth_typing import
|
|
14
|
+
from eth_typing import (
|
|
15
|
+
ChainId,
|
|
16
|
+
)
|
|
8
17
|
|
|
9
|
-
from faster_eth_utils import
|
|
18
|
+
from faster_eth_utils.exceptions import (
|
|
19
|
+
ValidationError,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
FASTER_ETH_UTILS_FOLDER: Final = Path(sys.modules["faster_eth_utils"].__file__).parent # type: ignore [arg-type]
|
|
10
24
|
|
|
11
25
|
|
|
12
26
|
@dataclass
|
|
@@ -17,15 +31,14 @@ class Network:
|
|
|
17
31
|
symbol: ChainId
|
|
18
32
|
|
|
19
33
|
|
|
20
|
-
def initialize_network_objects() ->
|
|
34
|
+
def initialize_network_objects() -> list[Network]:
|
|
21
35
|
networks_obj = []
|
|
22
36
|
|
|
23
37
|
networks_json_path = os.path.abspath(
|
|
24
|
-
os.path.join(
|
|
38
|
+
os.path.join(str(FASTER_ETH_UTILS_FOLDER), "__json")
|
|
25
39
|
)
|
|
26
40
|
with open(
|
|
27
41
|
os.path.join(networks_json_path, "eth_networks.json"),
|
|
28
|
-
"r",
|
|
29
42
|
encoding="UTF-8",
|
|
30
43
|
) as open_file:
|
|
31
44
|
network_data = json.load(open_file)
|
|
@@ -40,13 +53,11 @@ def initialize_network_objects() -> List[Network]:
|
|
|
40
53
|
)
|
|
41
54
|
networks_obj.append(network)
|
|
42
55
|
except ValueError:
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
f"a valid ChainId. eth-typing should be updated with the latest "
|
|
47
|
-
f"networks."
|
|
48
|
-
)
|
|
56
|
+
# Chain does not have a valid ChainId, network files in eth-utils and
|
|
57
|
+
# eth-typing should to be updated. Run `python update_networks.py` in the
|
|
58
|
+
# project root.
|
|
49
59
|
pass
|
|
60
|
+
|
|
50
61
|
return networks_obj
|
|
51
62
|
|
|
52
63
|
|
|
Binary file
|
faster_eth_utils/numeric.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
from abc import
|
|
1
|
+
from abc import (
|
|
2
|
+
ABC,
|
|
3
|
+
abstractmethod,
|
|
4
|
+
)
|
|
2
5
|
import decimal
|
|
3
6
|
import numbers
|
|
4
|
-
from typing import
|
|
7
|
+
from typing import (
|
|
8
|
+
Any,
|
|
9
|
+
TypeVar,
|
|
10
|
+
Union,
|
|
11
|
+
)
|
|
5
12
|
|
|
6
13
|
|
|
7
14
|
class Comparable(ABC):
|
|
@@ -22,11 +29,11 @@ TValue = TypeVar("TValue", bound=TComparable)
|
|
|
22
29
|
|
|
23
30
|
def clamp(lower_bound: TValue, upper_bound: TValue, value: TValue) -> TValue:
|
|
24
31
|
# The `mypy` ignore statements here are due to doing a comparison of
|
|
25
|
-
# `Union` types which isn't allowed. (per cburgdorf).
|
|
32
|
+
# `Union` types which isn't allowed. (per cburgdorf). This approach was
|
|
26
33
|
# chosen over using `typing.overload` to define multiple signatures for
|
|
27
34
|
# each comparison type here since the added value of "proper" typing
|
|
28
35
|
# doesn't seem to justify the complexity of having a bunch of different
|
|
29
|
-
# signatures defined.
|
|
36
|
+
# signatures defined. The external library perspective on this function
|
|
30
37
|
# should still be adequate under this approach
|
|
31
38
|
if value < lower_bound: # type: ignore
|
|
32
39
|
return lower_bound
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
from pydantic import (
|
|
6
|
+
BaseModel,
|
|
7
|
+
ConfigDict,
|
|
8
|
+
)
|
|
9
|
+
from pydantic._internal._core_utils import (
|
|
10
|
+
CoreSchemaField,
|
|
11
|
+
)
|
|
12
|
+
from pydantic.alias_generators import (
|
|
13
|
+
to_camel,
|
|
14
|
+
)
|
|
15
|
+
from pydantic.json_schema import (
|
|
16
|
+
DEFAULT_REF_TEMPLATE,
|
|
17
|
+
GenerateJsonSchema,
|
|
18
|
+
JsonSchemaMode,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class OmitJsonSchema(GenerateJsonSchema): # type: ignore[misc]
|
|
23
|
+
"""
|
|
24
|
+
Custom JSON schema generator that omits the schema generation for fields that are
|
|
25
|
+
invalid. Excluded fields (``Field(exclude=True)``) are generally useful as
|
|
26
|
+
properties of the model but are not meant to be serialized to JSON.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def field_is_present(self, field: CoreSchemaField) -> bool:
|
|
30
|
+
# override ``field_is_present`` and omit excluded fields from the schema
|
|
31
|
+
if field.get("serialization_exclude", False):
|
|
32
|
+
return False
|
|
33
|
+
return super().field_is_present(field)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CamelModel(BaseModel): # type: ignore[misc]
|
|
37
|
+
"""
|
|
38
|
+
Camel-case pydantic model. This model is used to ensure serialization in a
|
|
39
|
+
consistent manner, aliasing as camelCase serialization. This is useful for models
|
|
40
|
+
that are used in JSON-RPC requests and responses, marking useful fields for the
|
|
41
|
+
model, but that are not part of the JSON-RPC object, with ``Field(exclude=True)``.
|
|
42
|
+
To serialize a model to the expected JSON-RPC format, or camelCase, use
|
|
43
|
+
``model_dump(by_alias=True)``.
|
|
44
|
+
|
|
45
|
+
.. code-block:: python
|
|
46
|
+
|
|
47
|
+
>>> from eth_utils.pydantic import CamelModel
|
|
48
|
+
>>> from pydantic import Field
|
|
49
|
+
|
|
50
|
+
>>> class SignedSetCodeAuthorization(CamelModel):
|
|
51
|
+
... chain_id: int
|
|
52
|
+
... address: bytes
|
|
53
|
+
... nonce: int
|
|
54
|
+
...
|
|
55
|
+
... # useful fields for the object but excluded from serialization
|
|
56
|
+
... # (not part of the JSON-RPC object)
|
|
57
|
+
... authorization_hash: bytes = Field(exclude=True)
|
|
58
|
+
... signature: bytes = Field(exclude=True)
|
|
59
|
+
|
|
60
|
+
>>> auth = SignedSetCodeAuthorization(
|
|
61
|
+
... chain_id=1,
|
|
62
|
+
... address=b"0x0000000000000000000000000000000000000000",
|
|
63
|
+
... nonce=0,
|
|
64
|
+
... authorization_hash=generated_hash,
|
|
65
|
+
... signature=generated_signature,
|
|
66
|
+
... )
|
|
67
|
+
>>> auth.model_dump(by_alias=True)
|
|
68
|
+
{'chainId': 1, 'address': '0x000000000000000000000000000000000000', 'nonce': 0}
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
model_config = ConfigDict(
|
|
72
|
+
arbitrary_types_allowed=True,
|
|
73
|
+
# populate by snake_case (python) args
|
|
74
|
+
populate_by_name=True,
|
|
75
|
+
# serialize by camelCase (json-rpc) keys
|
|
76
|
+
alias_generator=to_camel,
|
|
77
|
+
# validate default values
|
|
78
|
+
validate_default=True,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def model_json_schema( # type: ignore [override]
|
|
83
|
+
cls,
|
|
84
|
+
by_alias: bool = True,
|
|
85
|
+
ref_template: str = DEFAULT_REF_TEMPLATE,
|
|
86
|
+
# default to ``OmitJsonSchema`` to prevent errors from excluded fields
|
|
87
|
+
schema_generator: type[GenerateJsonSchema] = OmitJsonSchema,
|
|
88
|
+
mode: JsonSchemaMode = "validation",
|
|
89
|
+
) -> dict[str, Any]:
|
|
90
|
+
"""
|
|
91
|
+
Omits excluded fields from the JSON schema, preventing errors that would
|
|
92
|
+
otherwise be raised by the default schema generator.
|
|
93
|
+
"""
|
|
94
|
+
return super().model_json_schema(
|
|
95
|
+
by_alias=by_alias,
|
|
96
|
+
ref_template=ref_template,
|
|
97
|
+
schema_generator=schema_generator,
|
|
98
|
+
mode=mode,
|
|
99
|
+
)
|
|
Binary file
|
faster_eth_utils/toolz.py
CHANGED
|
@@ -1,154 +1,84 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
|
|
1
3
|
try:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
assoc,
|
|
5
|
-
assoc_in,
|
|
6
|
-
comp,
|
|
7
|
-
complement,
|
|
8
|
-
compose,
|
|
9
|
-
concat,
|
|
10
|
-
concatv,
|
|
11
|
-
cons,
|
|
12
|
-
count,
|
|
13
|
-
countby,
|
|
14
|
-
curried,
|
|
15
|
-
curry,
|
|
16
|
-
dicttoolz,
|
|
17
|
-
diff,
|
|
18
|
-
dissoc,
|
|
19
|
-
do,
|
|
20
|
-
drop,
|
|
21
|
-
excepts,
|
|
22
|
-
filter,
|
|
23
|
-
first,
|
|
24
|
-
flip,
|
|
25
|
-
frequencies,
|
|
26
|
-
functoolz,
|
|
27
|
-
get,
|
|
28
|
-
get_in,
|
|
29
|
-
groupby,
|
|
30
|
-
identity,
|
|
31
|
-
interleave,
|
|
32
|
-
interpose,
|
|
33
|
-
isdistinct,
|
|
34
|
-
isiterable,
|
|
35
|
-
itemfilter,
|
|
36
|
-
itemmap,
|
|
37
|
-
iterate,
|
|
38
|
-
itertoolz,
|
|
39
|
-
join,
|
|
40
|
-
juxt,
|
|
41
|
-
keyfilter,
|
|
42
|
-
keymap,
|
|
43
|
-
last,
|
|
44
|
-
map,
|
|
45
|
-
mapcat,
|
|
46
|
-
memoize,
|
|
47
|
-
merge,
|
|
48
|
-
merge_sorted,
|
|
49
|
-
merge_with,
|
|
50
|
-
nth,
|
|
51
|
-
partial,
|
|
52
|
-
partition,
|
|
53
|
-
partition_all,
|
|
54
|
-
partitionby,
|
|
55
|
-
peek,
|
|
56
|
-
pipe,
|
|
57
|
-
pluck,
|
|
58
|
-
random_sample,
|
|
59
|
-
recipes,
|
|
60
|
-
reduce,
|
|
61
|
-
reduceby,
|
|
62
|
-
remove,
|
|
63
|
-
second,
|
|
64
|
-
sliding_window,
|
|
65
|
-
sorted,
|
|
66
|
-
tail,
|
|
67
|
-
take,
|
|
68
|
-
take_nth,
|
|
69
|
-
thread_first,
|
|
70
|
-
thread_last,
|
|
71
|
-
topk,
|
|
72
|
-
unique,
|
|
73
|
-
update_in,
|
|
74
|
-
utils,
|
|
75
|
-
valfilter,
|
|
76
|
-
valmap,
|
|
77
|
-
)
|
|
4
|
+
import cytoolz
|
|
5
|
+
cy = True
|
|
78
6
|
except ImportError:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
7
|
+
import toolz
|
|
8
|
+
cy = False
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
accumulate: Final = cytoolz.accumulate if cy else toolz.accumulate
|
|
12
|
+
assoc: Final = cytoolz.assoc if cy else toolz.assoc
|
|
13
|
+
assoc_in: Final = cytoolz.assoc_in if cy else toolz.assoc_in
|
|
14
|
+
comp: Final = cytoolz.comp if cy else toolz.comp
|
|
15
|
+
complement: Final = cytoolz.complement if cy else toolz.complement
|
|
16
|
+
compose: Final = cytoolz.compose if cy else toolz.compose
|
|
17
|
+
concat: Final = cytoolz.concat if cy else toolz.concat
|
|
18
|
+
concatv: Final = cytoolz.concatv if cy else toolz.concatv
|
|
19
|
+
cons: Final = cytoolz.cons if cy else toolz.cons
|
|
20
|
+
count: Final = cytoolz.count if cy else toolz.count
|
|
21
|
+
countby: Final = cytoolz.countby if cy else toolz.countby
|
|
22
|
+
curried: Final = cytoolz.curried if cy else toolz.curried
|
|
23
|
+
curry: Final = cytoolz.curry if cy else toolz.curry
|
|
24
|
+
dicttoolz: Final = cytoolz.dicttoolz if cy else toolz.dicttoolz
|
|
25
|
+
diff: Final = cytoolz.diff if cy else toolz.diff
|
|
26
|
+
dissoc: Final = cytoolz.dissoc if cy else toolz.dissoc
|
|
27
|
+
do: Final = cytoolz.do if cy else toolz.do
|
|
28
|
+
drop: Final = cytoolz.drop if cy else toolz.drop
|
|
29
|
+
excepts: Final = cytoolz.excepts if cy else toolz.excepts
|
|
30
|
+
filter: Final = cytoolz.filter if cy else toolz.filter
|
|
31
|
+
first: Final = cytoolz.first if cy else toolz.first
|
|
32
|
+
flip: Final = cytoolz.flip if cy else toolz.flip
|
|
33
|
+
frequencies: Final = cytoolz.frequencies if cy else toolz.frequencies
|
|
34
|
+
functoolz: Final = cytoolz.functoolz if cy else toolz.functoolz
|
|
35
|
+
get: Final = cytoolz.get if cy else toolz.get
|
|
36
|
+
get_in: Final = cytoolz.get_in if cy else toolz.get_in
|
|
37
|
+
groupby: Final = cytoolz.groupby if cy else toolz.groupby
|
|
38
|
+
identity: Final = cytoolz.identity if cy else toolz.identity
|
|
39
|
+
interleave: Final = cytoolz.interleave if cy else toolz.interleave
|
|
40
|
+
interpose: Final = cytoolz.interpose if cy else toolz.interpose
|
|
41
|
+
isdistinct: Final = cytoolz.isdistinct if cy else toolz.isdistinct
|
|
42
|
+
isiterable: Final = cytoolz.isiterable if cy else toolz.isiterable
|
|
43
|
+
itemfilter: Final = cytoolz.itemfilter if cy else toolz.itemfilter
|
|
44
|
+
itemmap: Final = cytoolz.itemmap if cy else toolz.itemmap
|
|
45
|
+
iterate: Final = cytoolz.iterate if cy else toolz.iterate
|
|
46
|
+
itertoolz: Final = cytoolz.itertoolz if cy else toolz.itertoolz
|
|
47
|
+
join: Final = cytoolz.join if cy else toolz.join
|
|
48
|
+
juxt: Final = cytoolz.juxt if cy else toolz.juxt
|
|
49
|
+
keyfilter: Final = cytoolz.keyfilter if cy else toolz.keyfilter
|
|
50
|
+
keymap: Final = cytoolz.keymap if cy else toolz.keymap
|
|
51
|
+
last: Final = cytoolz.last if cy else toolz.last
|
|
52
|
+
map: Final = cytoolz.map if cy else toolz.map
|
|
53
|
+
mapcat: Final = cytoolz.mapcat if cy else toolz.mapcat
|
|
54
|
+
memoize: Final = cytoolz.memoize if cy else toolz.memoize
|
|
55
|
+
merge: Final = cytoolz.merge if cy else toolz.merge
|
|
56
|
+
merge_sorted: Final = cytoolz.merge_sorted if cy else toolz.merge_sorted
|
|
57
|
+
merge_with: Final = cytoolz.merge_with if cy else toolz.merge_with
|
|
58
|
+
nth: Final = cytoolz.nth if cy else toolz.nth
|
|
59
|
+
partial: Final = cytoolz.partial if cy else toolz.partial
|
|
60
|
+
partition: Final = cytoolz.partition if cy else toolz.partition
|
|
61
|
+
partition_all: Final = cytoolz.partition_all if cy else toolz.partition_all
|
|
62
|
+
partitionby: Final = cytoolz.partitionby if cy else toolz.partitionby
|
|
63
|
+
peek: Final = cytoolz.peek if cy else toolz.peek
|
|
64
|
+
pipe: Final = cytoolz.pipe if cy else toolz.pipe
|
|
65
|
+
pluck: Final = cytoolz.pluck if cy else toolz.pluck
|
|
66
|
+
random_sample: Final = cytoolz.random_sample if cy else toolz.random_sample
|
|
67
|
+
recipes: Final = cytoolz.recipes if cy else toolz.recipes
|
|
68
|
+
reduce: Final = cytoolz.reduce if cy else toolz.reduce
|
|
69
|
+
reduceby: Final = cytoolz.reduceby if cy else toolz.reduceby
|
|
70
|
+
remove: Final = cytoolz.remove if cy else toolz.remove
|
|
71
|
+
second: Final = cytoolz.second if cy else toolz.second
|
|
72
|
+
sliding_window: Final = cytoolz.sliding_window if cy else toolz.sliding_window
|
|
73
|
+
sorted: Final = cytoolz.sorted if cy else toolz.sorted
|
|
74
|
+
tail: Final = cytoolz.tail if cy else toolz.tail
|
|
75
|
+
take: Final = cytoolz.take if cy else toolz.take
|
|
76
|
+
take_nth: Final = cytoolz.take_nth if cy else toolz.take_nth
|
|
77
|
+
thread_first: Final = cytoolz.thread_first if cy else toolz.thread_first
|
|
78
|
+
thread_last: Final = cytoolz.thread_last if cy else toolz.thread_last
|
|
79
|
+
topk: Final = cytoolz.topk if cy else toolz.topk
|
|
80
|
+
unique: Final = cytoolz.unique if cy else toolz.unique
|
|
81
|
+
update_in: Final = cytoolz.update_in if cy else toolz.update_in
|
|
82
|
+
utils: Final = cytoolz.utils if cy else toolz.utils
|
|
83
|
+
valfilter: Final = cytoolz.valfilter if cy else toolz.valfilter
|
|
84
|
+
valmap: Final = cytoolz.valmap if cy else toolz.valmap
|
|
Binary file
|
faster_eth_utils/types.py
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
1
|
import collections.abc
|
|
2
2
|
import numbers
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import (
|
|
4
|
+
Any,
|
|
5
|
+
Final,
|
|
6
|
+
Literal,
|
|
7
|
+
)
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
string_types = (bytes, str, bytearray)
|
|
9
|
+
from typing import (
|
|
10
|
+
TypeGuard,
|
|
11
|
+
)
|
|
9
12
|
|
|
13
|
+
Mapping: Final = collections.abc.Mapping
|
|
14
|
+
Sequence: Final = collections.abc.Sequence
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
return isinstance(value, integer_types) and not isinstance(value, bool)
|
|
16
|
+
Number: Final = numbers.Number
|
|
13
17
|
|
|
18
|
+
bytes_types: Final = (bytes, bytearray)
|
|
19
|
+
integer_types: Final = (int,)
|
|
20
|
+
text_types: Final = (str,)
|
|
21
|
+
string_types: Final = (bytes, str, bytearray)
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
|
|
24
|
+
def is_integer(value: Any) -> TypeGuard[int]:
|
|
25
|
+
return isinstance(value, int) and not isinstance(value, bool)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_bytes(value: Any) -> TypeGuard[bytes | bytearray]:
|
|
16
29
|
return isinstance(value, bytes_types)
|
|
17
30
|
|
|
18
31
|
|
|
19
|
-
def is_text(value: Any) ->
|
|
20
|
-
return isinstance(value,
|
|
32
|
+
def is_text(value: Any) -> TypeGuard[str]:
|
|
33
|
+
return isinstance(value, str)
|
|
21
34
|
|
|
22
35
|
|
|
23
|
-
def is_string(value: Any) ->
|
|
36
|
+
def is_string(value: Any) -> TypeGuard[bytes | str | bytearray]:
|
|
24
37
|
return isinstance(value, string_types)
|
|
25
38
|
|
|
26
39
|
|
|
27
|
-
def is_boolean(value: Any) -> bool:
|
|
40
|
+
def is_boolean(value: Any) -> TypeGuard[bool]:
|
|
28
41
|
return isinstance(value, bool)
|
|
29
42
|
|
|
30
43
|
|
|
31
|
-
def is_dict(obj: Any) ->
|
|
32
|
-
return isinstance(obj,
|
|
44
|
+
def is_dict(obj: Any) -> TypeGuard[collections.abc.Mapping[Any, Any]]:
|
|
45
|
+
return isinstance(obj, dict) or isinstance(obj, Mapping)
|
|
33
46
|
|
|
34
47
|
|
|
35
|
-
def is_list_like(obj: Any) ->
|
|
36
|
-
return not is_string(obj) and isinstance(obj,
|
|
48
|
+
def is_list_like(obj: Any) -> TypeGuard[collections.abc.Sequence[Any]]:
|
|
49
|
+
return isinstance(obj, (list, tuple)) or not is_string(obj) and isinstance(obj, Sequence)
|
|
37
50
|
|
|
38
51
|
|
|
39
|
-
def is_list(obj: Any) ->
|
|
52
|
+
def is_list(obj: Any) -> TypeGuard[list[Any]]:
|
|
40
53
|
return isinstance(obj, list)
|
|
41
54
|
|
|
42
55
|
|
|
43
|
-
def is_tuple(obj: Any) ->
|
|
56
|
+
def is_tuple(obj: Any) -> TypeGuard[tuple[Any, ...]]:
|
|
44
57
|
return isinstance(obj, tuple)
|
|
45
58
|
|
|
46
59
|
|
|
47
|
-
def is_null(obj: Any) ->
|
|
60
|
+
def is_null(obj: Any) -> TypeGuard[Literal[None]]:
|
|
48
61
|
return obj is None
|
|
49
62
|
|
|
50
63
|
|
|
51
|
-
def is_number(obj: Any) ->
|
|
52
|
-
return isinstance(obj,
|
|
64
|
+
def is_number(obj: Any) -> TypeGuard[numbers.Number]:
|
|
65
|
+
return isinstance(obj, Number)
|
faster_eth_utils/typing/misc.py
CHANGED
|
Binary file
|