@@ -471,36 +471,12 @@ class InputMultiObject(MultiObject):
471471OutputMultiPath = OutputMultiObject
472472
473473
474- class Tuple (traits .BaseTuple ):
475- """Defines a new type of Tuple trait that reports inner types."""
476-
477- def init_fast_validator (self , * args ):
478- """Set up the C-level fast validator."""
479- super (Tuple , self ).init_fast_validator (* args )
480- self .fast_validate = args
481-
482- def inner_traits (self ):
483- """Return the *inner trait* (or traits) for this trait."""
484- return self .types
485-
486-
487- class Either (TraitType ):
488- """Defines a trait whose value can be any of of a specified list of traits."""
489-
490- def __init__ (self , * traits , ** metadata ):
491- """Create a trait whose value can be any of of a specified list of traits."""
492- _either_traits = tuple (trait_from (t ) for t in traits )
493- self .trait_maker = _TraitMaker (
494- metadata .pop ("default" , None ), * traits , ** metadata )
495- self .either_traits = _either_traits
474+ class Tuple (traits .Tuple ):
475+ pass
496476
497- def as_ctrait (self ):
498- """Return a CTrait corresponding to the trait defined by this class."""
499- return self .trait_maker .as_ctrait ()
500477
501- def inner_traits (self ):
502- """Return the *inner trait* (or traits) for this trait."""
503- return self .either_traits
478+ class Either (traits .Either ):
479+ pass
504480
505481
506482traits .Tuple = Tuple
@@ -548,22 +524,22 @@ def _recurse_on_path_traits(func, thistrait, value, cwd):
548524
549525 value = [_recurse_on_path_traits (func , innertrait , v , cwd )
550526 for v in value ]
551- elif thistrait .is_trait_type (traits .Dict ):
527+ elif isinstance ( value , dict ) and thistrait .is_trait_type (traits .Dict ):
552528 _ , innertrait = thistrait .inner_traits
553529 value = {k : _recurse_on_path_traits (func , innertrait , v , cwd )
554530 for k , v in value .items ()}
555- elif thistrait .is_trait_type (Tuple ):
531+ elif isinstance ( value , tuple ) and thistrait .is_trait_type (Tuple ):
556532 value = tuple ([_recurse_on_path_traits (func , subtrait , v , cwd )
557- for subtrait , v in zip (thistrait .inner_traits , value )])
558- elif thistrait .is_trait_type (Either ):
559- is_str = [f . is_trait_type ( (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
560- for f in thistrait .inner_traits ]
533+ for subtrait , v in zip (thistrait .handler . types , value )])
534+ elif thistrait .is_trait_type (traits . TraitCompound ):
535+ is_str = [isinstance ( f , (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
536+ for f in thistrait .handler . handlers ]
561537 if any (is_str ) and isinstance (value , (bytes , str )) and not value .startswith ('/' ):
562538 return value
563- is_basepath = [ f . is_trait_type ( BasePath ) for f in thistrait . inner_traits ]
564- if any ( is_basepath ) :
565- subtrait = thistrait . inner_traits [ is_basepath . index ( True )]
566- value = _recurse_on_path_traits ( func , subtrait , value , cwd )
539+
540+ for subtrait in thistrait . handler . handlers :
541+ value = _recurse_on_path_traits ( func , subtrait (), value , cwd )
542+
567543 return value
568544
569545
0 commit comments