typedparser 0.22.3__tar.gz → 0.22.6__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.
- {typedparser-0.22.3 → typedparser-0.22.6}/PKG-INFO +2 -2
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/__init__.py +1 -1
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/objects.py +38 -11
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/PKG-INFO +2 -2
- {typedparser-0.22.3 → typedparser-0.22.6}/LICENSE +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/README.md +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/pyproject.toml +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/requirements.txt +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/setup.cfg +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/_typedattr.py +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/_typedparser.py +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/custom_format.py +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser/funcs.py +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/SOURCES.txt +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/dependency_links.txt +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/requires.txt +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/top_level.txt +0 -0
- {typedparser-0.22.3 → typedparser-0.22.6}/src/typedparser.egg-info/zip-safe +0 -0
|
@@ -26,10 +26,26 @@ def get_attr_names(cls: AttrsClass) -> List[str]:
|
|
|
26
26
|
return [att.name for att in fields(cls)] # noqa
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
# def _get_all_base_classes_rec(klass: type) -> Generator[type, None, None]:
|
|
30
|
+
# for base in klass.__bases__:
|
|
31
|
+
# yield base
|
|
32
|
+
# yield from _get_all_base_classes_rec(base)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_all_base_classes(input_class: type) -> List[type]:
|
|
36
|
+
classes = {}
|
|
37
|
+
|
|
38
|
+
def _get_all_base_classes_rec(class_here: type):
|
|
39
|
+
for base in class_here.__bases__:
|
|
40
|
+
if base == object:
|
|
41
|
+
continue
|
|
42
|
+
if base in classes:
|
|
43
|
+
continue
|
|
44
|
+
classes[base] = base
|
|
45
|
+
_get_all_base_classes_rec(base)
|
|
46
|
+
|
|
47
|
+
_get_all_base_classes_rec(input_class)
|
|
48
|
+
return list(classes.values())
|
|
33
49
|
|
|
34
50
|
|
|
35
51
|
def is_standard_mapping(d: Any) -> bool:
|
|
@@ -150,7 +166,9 @@ def flatten_dict(
|
|
|
150
166
|
parser = parser_class()
|
|
151
167
|
|
|
152
168
|
def _check_key(key_inner):
|
|
153
|
-
assert
|
|
169
|
+
assert (
|
|
170
|
+
separator_for_dict not in key_inner and separator_for_list not in key_inner
|
|
171
|
+
), (
|
|
154
172
|
f"Separators '{separator_for_dict}' and '{separator_for_list}' not allowed in key "
|
|
155
173
|
f"'{key_inner}' when flattening dict."
|
|
156
174
|
)
|
|
@@ -162,7 +180,9 @@ def flatten_dict(
|
|
|
162
180
|
k_inner_str = str(k_inner)
|
|
163
181
|
_check_key(k_inner_str)
|
|
164
182
|
items_inner.extend(
|
|
165
|
-
_flatten_leaf(
|
|
183
|
+
_flatten_leaf(
|
|
184
|
+
v_inner, prefix=f"{prefix}{separator_for_dict}{k_inner_str}"
|
|
185
|
+
)
|
|
166
186
|
)
|
|
167
187
|
elif parser.is_iterable_fn(d_inner):
|
|
168
188
|
for i, v_inner in enumerate(d_inner):
|
|
@@ -234,7 +254,9 @@ def compare_nested_objects(
|
|
|
234
254
|
else:
|
|
235
255
|
for i, v in enumerate(d1):
|
|
236
256
|
all_errors.extend(
|
|
237
|
-
_compare_nested_objects(
|
|
257
|
+
_compare_nested_objects(
|
|
258
|
+
v, d2[i], depth + 1, prefix=f"{prefix}[{i}]"
|
|
259
|
+
)
|
|
238
260
|
)
|
|
239
261
|
return all_errors
|
|
240
262
|
|
|
@@ -251,7 +273,9 @@ def compare_nested_objects(
|
|
|
251
273
|
# check if attributes are defined in the same way
|
|
252
274
|
d1_att = getattr(d1, att_name)
|
|
253
275
|
d2_att = getattr(d2, att_name)
|
|
254
|
-
if type(d1_att) != type(
|
|
276
|
+
if type(d1_att) != type(
|
|
277
|
+
d2_att
|
|
278
|
+
): # noqa # pylint: disable=unidiomatic-typecheck
|
|
255
279
|
all_errors.append(
|
|
256
280
|
f"{prefix} Attribute {att_name} type mismatch: "
|
|
257
281
|
f"({type(d1_att)}) != ({type(d2_att)})"
|
|
@@ -274,9 +298,10 @@ def compare_nested_objects(
|
|
|
274
298
|
def _compare_leaf(
|
|
275
299
|
d1: Any, d2: Any, _depth: int, rtol=1.0e-5, atol=1.0e-8, equal_nan=False, prefix=""
|
|
276
300
|
) -> List[str]:
|
|
301
|
+
|
|
277
302
|
# at this point the 2 leaves are guaranteed to be the same type
|
|
278
|
-
if np is not None and isinstance(d1, np.ndarray):
|
|
279
|
-
comp = np.allclose(d1, d2, rtol=rtol, atol=atol, equal_nan=equal_nan)
|
|
303
|
+
if np is not None and isinstance(d1, np.ndarray): # noqa
|
|
304
|
+
comp = np.allclose(d1, d2, rtol=rtol, atol=atol, equal_nan=equal_nan) # noqa
|
|
280
305
|
else:
|
|
281
306
|
comp = d1 == d2
|
|
282
307
|
if not comp:
|
|
@@ -321,7 +346,9 @@ def big_obj_to_short_str(d: Any) -> str:
|
|
|
321
346
|
return f"Object of type {class_name}"
|
|
322
347
|
|
|
323
348
|
|
|
324
|
-
def invert_dict_of_dict(
|
|
349
|
+
def invert_dict_of_dict(
|
|
350
|
+
dict_of_dict: dict[str, dict[str, any]]
|
|
351
|
+
) -> dict[str, dict[str, any]]:
|
|
325
352
|
"""
|
|
326
353
|
Invert a dictionary of dictionaries. Useful for creating dataframes.
|
|
327
354
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|