Skip to content

Commit ca0833c

Browse files
tcloseeffigies
andauthored
Update pydra/utils/typing.py
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 1bec68c commit ca0833c

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

pydra/utils/typing.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -551,21 +551,20 @@ def check_sequence(tp_args, pattern_args):
551551
return expand_and_check(type_, self.pattern)
552552
except TypeError as e:
553553
# Special handling for MultiInputObjects (which are annoying)
554-
if isinstance(self.pattern, tuple) and self.pattern[0] == MultiInputObj:
555-
# Attempt to coerce the object into arg type of the MultiInputObj first,
556-
# and if that fails, try to coerce it into a list of the arg type
557-
inner_type_parser = copy(self)
558-
inner_type_parser.pattern = self.pattern[1][0]
559-
try:
560-
inner_type_parser.check_type(type_)
561-
except TypeError:
562-
add_exc_note(
563-
e,
564-
"Also failed to coerce to the arg-type of the MultiInputObj "
565-
f"({self.pattern[1][0]})",
566-
)
567-
raise e
568-
else:
554+
if not isinstance(self.pattern, tuple) or self.pattern[0] != MultiInputObj:
555+
raise e
556+
# Attempt to coerce the object into arg type of the MultiInputObj first,
557+
# and if that fails, try to coerce it into a list of the arg type
558+
inner_type_parser = copy(self)
559+
inner_type_parser.pattern = self.pattern[1][0]
560+
try:
561+
inner_type_parser.check_type(type_)
562+
except TypeError:
563+
add_exc_note(
564+
e,
565+
"Also failed to coerce to the arg-type of the MultiInputObj "
566+
f"({self.pattern[1][0]})",
567+
)
569568
raise e
570569

571570
def check_coercible(self, source: ty.Any, target: ty.Union[type, ty.Any]):

0 commit comments

Comments
 (0)