typedparser 0.31.3__tar.gz → 0.32.2__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.31.3 → typedparser-0.32.2}/PKG-INFO +1 -1
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/__init__.py +5 -5
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/_typedattr.py +12 -12
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/_typedparser.py +4 -3
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/funcs.py +1 -1
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/objects.py +9 -6
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/PKG-INFO +1 -1
- {typedparser-0.31.3 → typedparser-0.32.2}/LICENSE +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/README.md +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/pyproject.toml +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/requirements.txt +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/setup.cfg +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser/custom_format.py +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/SOURCES.txt +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/dependency_links.txt +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/requires.txt +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/top_level.txt +0 -0
- {typedparser-0.31.3 → typedparser-0.32.2}/src/typedparser.egg-info/zip-safe +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from ._typedattr import
|
|
1
|
+
from ._typedattr import NamedTupleMixin, attrs_from_dict, definenumpy
|
|
2
2
|
from ._typedparser import (
|
|
3
|
-
|
|
3
|
+
TaskSplitterArgs,
|
|
4
4
|
TypedParser,
|
|
5
5
|
VerboseQuietArgs,
|
|
6
|
-
|
|
7
|
-
split_list_given_task_splitter_args,
|
|
6
|
+
add_argument,
|
|
8
7
|
split_list_for_processing,
|
|
8
|
+
split_list_given_task_splitter_args,
|
|
9
9
|
)
|
|
10
10
|
from .custom_format import CustomArgparseFmt
|
|
11
11
|
from .objects import get_attr_names
|
|
@@ -25,4 +25,4 @@ __all__ = [
|
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
__version__ = "0.
|
|
28
|
+
__version__ = "0.32.2"
|
|
@@ -5,33 +5,33 @@ from functools import partial
|
|
|
5
5
|
from inspect import isclass
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from typing import (
|
|
8
|
-
Tuple,
|
|
9
|
-
Union,
|
|
10
|
-
Dict,
|
|
11
8
|
AbstractSet,
|
|
12
|
-
Iterable,
|
|
13
|
-
Mapping,
|
|
14
|
-
Collection,
|
|
15
|
-
Type,
|
|
16
9
|
Any,
|
|
10
|
+
Callable,
|
|
11
|
+
Collection,
|
|
12
|
+
Dict,
|
|
13
|
+
Iterable,
|
|
17
14
|
List,
|
|
15
|
+
Mapping,
|
|
18
16
|
Optional,
|
|
17
|
+
Tuple,
|
|
18
|
+
Type,
|
|
19
|
+
Union,
|
|
19
20
|
get_type_hints,
|
|
20
|
-
Callable,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
import attrs
|
|
24
|
-
from attr import
|
|
25
|
-
from attrs import
|
|
24
|
+
from attr import AttrsInstance, has
|
|
25
|
+
from attrs import Attribute, define, fields, fields_dict
|
|
26
26
|
|
|
27
|
-
from .objects import
|
|
27
|
+
from .objects import AttrsClass, RecursorInterface, StrictRecursor, check_object_equality
|
|
28
28
|
|
|
29
29
|
try:
|
|
30
30
|
from types import UnionType
|
|
31
31
|
except ImportError:
|
|
32
32
|
UnionType = None
|
|
33
33
|
|
|
34
|
-
from typing import
|
|
34
|
+
from typing import get_args, get_origin
|
|
35
35
|
|
|
36
36
|
# default conversions allow to convert instead of raising errors in case of matching types
|
|
37
37
|
# e.g. create Path given str, or create float given int
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# from __future__ import annotations # do not use here, it breaks everything
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
-
from attr import field, define
|
|
5
4
|
from dataclasses import dataclass
|
|
6
|
-
from typing import Optional, Type
|
|
5
|
+
from typing import Any, Optional, Type
|
|
6
|
+
|
|
7
|
+
from attr import define, field
|
|
7
8
|
|
|
8
9
|
from ._typedattr import AttrsClass
|
|
9
10
|
from .custom_format import CustomArgparseFmt
|
|
10
|
-
from .funcs import
|
|
11
|
+
from .funcs import add_typed_args, parse_typed_args
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
@dataclass
|
|
@@ -7,12 +7,12 @@ from __future__ import annotations
|
|
|
7
7
|
import inspect
|
|
8
8
|
from abc import ABCMeta, abstractmethod
|
|
9
9
|
from collections import defaultdict
|
|
10
|
-
from collections.abc import
|
|
10
|
+
from collections.abc import Iterable, Mapping
|
|
11
11
|
from copy import deepcopy
|
|
12
12
|
from functools import partial
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import Any, Callable, List, Type
|
|
14
14
|
|
|
15
|
-
from attr import
|
|
15
|
+
from attr import AttrsInstance, has
|
|
16
16
|
from attrs import fields
|
|
17
17
|
|
|
18
18
|
AttrsClass = Type[AttrsInstance]
|
|
@@ -105,6 +105,7 @@ def modify_nested_object(
|
|
|
105
105
|
modifier_fn: Callable,
|
|
106
106
|
return_copy: bool = False,
|
|
107
107
|
parser_class: Type[RecursorInterface] = StrictRecursor,
|
|
108
|
+
tuple_to_list: bool = False,
|
|
108
109
|
) -> Any:
|
|
109
110
|
"""
|
|
110
111
|
Traverse a python object and apply a modifier function to all leaves.
|
|
@@ -116,6 +117,7 @@ def modify_nested_object(
|
|
|
116
117
|
modifier_fn: modifier function to apply to all leaves
|
|
117
118
|
return_copy: whether to copy the object before modifying it
|
|
118
119
|
parser_class: which parser to use for iterable and mapping checks
|
|
120
|
+
tuple_to_list: if True, convert tuples to lists
|
|
119
121
|
|
|
120
122
|
Examples:
|
|
121
123
|
>>> e_dict = {'a': 1, 'b': {'c': 2, 'd': 3}}
|
|
@@ -126,16 +128,17 @@ def modify_nested_object(
|
|
|
126
128
|
|
|
127
129
|
"""
|
|
128
130
|
parser = parser_class()
|
|
131
|
+
tuple_type = list if tuple_to_list else tuple
|
|
132
|
+
if return_copy:
|
|
133
|
+
d = deepcopy(d)
|
|
129
134
|
|
|
130
135
|
def _modify_nested_object(d_inner: Any, depth: int = 0) -> Any:
|
|
131
136
|
recursive_fn = partial(_modify_nested_object, depth=depth + 1)
|
|
132
|
-
if return_copy:
|
|
133
|
-
d_inner = deepcopy(d_inner)
|
|
134
137
|
if parser.is_mapping_fn(d_inner):
|
|
135
138
|
for k, v in d_inner.items():
|
|
136
139
|
d_inner[k] = recursive_fn(v)
|
|
137
140
|
elif isinstance(d_inner, tuple): # tuple does not support in-place modification
|
|
138
|
-
d_inner =
|
|
141
|
+
d_inner = tuple_type(recursive_fn(v) for v in d_inner)
|
|
139
142
|
elif isinstance(d_inner, set): # set does not support in-place modification
|
|
140
143
|
d_inner = set(recursive_fn(v) for v in d_inner)
|
|
141
144
|
elif parser.is_iterable_fn(d_inner):
|
|
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
|