typedparser 0.11.1__tar.gz → 0.11.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.11.1
3
+ Version: 0.11.2
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
5
  Author: simon-ging
6
6
  License: Apache-2.0
@@ -28,5 +28,5 @@ def define(*args, **kwargs):
28
28
  )
29
29
 
30
30
 
31
- __version__ = "0.11.1"
31
+ __version__ = "0.11.2"
32
32
 
@@ -1,7 +1,4 @@
1
- import attrs
2
1
  import collections
3
- from attr import has, AttrsInstance
4
- from attrs import define, fields_dict, fields, Attribute
5
2
  from functools import partial
6
3
  from inspect import isclass
7
4
  from pathlib import Path
@@ -21,6 +18,10 @@ from typing import (
21
18
  Callable,
22
19
  )
23
20
 
21
+ import attrs
22
+ from attr import has, AttrsInstance
23
+ from attrs import define, fields_dict, fields, Attribute
24
+
24
25
  from .objects import check_object_equality, RecursorInterface, StrictRecursor, AttrsClass
25
26
 
26
27
  try:
@@ -319,14 +320,19 @@ def _parse_nested(
319
320
 
320
321
  # resolve unions (mostly "optional")
321
322
  if origin == Union or (UnionType is not None and isinstance(typ, UnionType)):
323
+ collected_errors = []
322
324
  for new_typ in args:
323
325
  try:
324
326
  # force strict parsing and catch errors to try all different types
325
327
  return parse_recursive(name, value, new_typ, strict=True)
326
- except TypeError:
327
- pass
328
+ except TypeError as e:
329
+ collected_errors.append(f"{e}")
328
330
  # if we get here, none of the types worked
329
- return maybe_raise_typeerror(f"{err_msg}. No type in Union matches.")
331
+ collected_error_str = "\n".join(collected_errors)
332
+ return maybe_raise_typeerror(
333
+ f"No type in Union matches. Errors per type:\n{collected_error_str}\n"
334
+ f"Final error: {err_msg}"
335
+ )
330
336
 
331
337
  final_list_type = None
332
338
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.11.1
3
+ Version: 0.11.2
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