@@ -45,26 +45,24 @@ def __getnewargs__(self) -> Tuple[str, Union[int, str], Any]:
4545
4646
4747class IterableValidationError (BaseValidationError ):
48- """Raised when structuring an iterable."""
48+ """Raised when structuring an iterable.
4949
50- def group_exceptions (
51- self ,
52- ) -> Tuple [List [Tuple [Exception , IterableValidationNote ]], List [Exception ]]:
53- """Split the exceptions into two groups: with and without validation notes."""
50+ If instantiating this error manually (outside of cattrs), ensure every
51+ subexception has an appropriate IterableValidationNote note in its notes.
52+ """
53+
54+ def group_exceptions (self ) -> List [Tuple [Exception , IterableValidationNote ]]:
55+ """Group up the subexceptions alongside their IV notes."""
5456 excs_with_notes = []
55- other_excs = []
5657 for subexc in self .exceptions :
57- if hasattr (subexc , "__notes__" ):
58- for note in subexc .__notes__ :
59- if note .__class__ is IterableValidationNote :
60- excs_with_notes .append ((subexc , note ))
61- break
62- else :
63- other_excs .append (subexc )
58+ for note in subexc .__notes__ :
59+ if note .__class__ is IterableValidationNote :
60+ excs_with_notes .append ((subexc , note ))
61+ break
6462 else :
65- other_excs . append ( subexc )
63+ raise AttributeError ( "Subexceptions require notes" )
6664
67- return excs_with_notes , other_excs
65+ return excs_with_notes
6866
6967
7068class AttributeValidationNote (str ):
0 commit comments