typedparser 0.31.2__tar.gz → 0.31.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.31.2
3
+ Version: 0.31.3
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
5
  Author: simon-ging
6
6
  License: Apache-2.0
@@ -25,4 +25,4 @@ __all__ = [
25
25
  ]
26
26
 
27
27
 
28
- __version__ = "0.31.2"
28
+ __version__ = "0.31.3"
@@ -109,6 +109,8 @@ def modify_nested_object(
109
109
  """
110
110
  Traverse a python object and apply a modifier function to all leaves.
111
111
 
112
+ Note: This also modifies tuples and sets.
113
+
112
114
  Args:
113
115
  d: object to modify (e.g. dict)
114
116
  modifier_fn: modifier function to apply to all leaves
@@ -132,6 +134,10 @@ def modify_nested_object(
132
134
  if parser.is_mapping_fn(d_inner):
133
135
  for k, v in d_inner.items():
134
136
  d_inner[k] = recursive_fn(v)
137
+ elif isinstance(d_inner, tuple): # tuple does not support in-place modification
138
+ d_inner = tuple(recursive_fn(v) for v in d_inner)
139
+ elif isinstance(d_inner, set): # set does not support in-place modification
140
+ d_inner = set(recursive_fn(v) for v in d_inner)
135
141
  elif parser.is_iterable_fn(d_inner):
136
142
  for i, v in enumerate(d_inner):
137
143
  d_inner[i] = recursive_fn(v)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.31.2
3
+ Version: 0.31.3
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
5
  Author: simon-ging
6
6
  License: Apache-2.0
File without changes
File without changes
File without changes