2121 extract_fields_from_class ,
2222 ensure_field_objects ,
2323 build_task_class ,
24+ sanitize_xor ,
2425 NO_DEFAULT ,
2526)
2627from pydra .utils .typing import (
@@ -208,7 +209,7 @@ def make(
208209 )
209210
210211 # Set positions for the remaining inputs that don't have an explicit position
211- position_stack = remaining_positions (list (parsed_inputs .values ()))
212+ position_stack = remaining_positions (list (parsed_inputs .values ()), xor = xor )
212213 for inpt in parsed_inputs .values ():
213214 if inpt .name == "append_args" :
214215 continue
@@ -526,7 +527,10 @@ def from_type_str(type_str) -> type:
526527
527528
528529def remaining_positions (
529- args : list [Arg ], num_args : int | None = None , start : int = 0
530+ args : list [Arg ],
531+ num_args : int | None = None ,
532+ start : int = 0 ,
533+ xor : set [frozenset [str ]] | None = None ,
530534) -> ty .List [int ]:
531535 """Get the remaining positions for input fields
532536
@@ -536,6 +540,10 @@ def remaining_positions(
536540 The list of input fields
537541 num_args : int, optional
538542 The number of arguments, by default it is the length of the args
543+ start : int, optional
544+ The starting position, by default 0
545+ xor : set[frozenset[str]], optional
546+ A set of mutually exclusive fields, by default None
539547
540548 Returns
541549 -------
@@ -547,6 +555,7 @@ def remaining_positions(
547555 ValueError
548556 If multiple fields have the same position
549557 """
558+ xor = sanitize_xor (xor )
550559 if num_args is None :
551560 num_args = len (args ) - 1 # Subtract 1 for the 'append_args' field
552561 # Check for multiple positions
@@ -562,7 +571,7 @@ def remaining_positions(
562571 if multiple_positions := {
563572 k : [f"{ a .name } ({ a .position } )" for a in v ]
564573 for k , v in positions .items ()
565- if len (v ) > 1
574+ if len (v ) > 1 and not any ( x . issuperset ( a . name for a in v ) for x in xor )
566575 }:
567576 raise ValueError (
568577 f"Multiple fields have the overlapping positions: { multiple_positions } "
0 commit comments