@@ -468,36 +468,12 @@ class InputMultiObject(MultiObject):
468468OutputMultiPath = OutputMultiObject
469469
470470
471- class Tuple (traits .BaseTuple ):
472- """Defines a new type of Tuple trait that reports inner types."""
473-
474- def init_fast_validator (self , * args ):
475- """Set up the C-level fast validator."""
476- super (Tuple , self ).init_fast_validator (* args )
477- self .fast_validate = args
478-
479- def inner_traits (self ):
480- """Return the *inner trait* (or traits) for this trait."""
481- return self .types
482-
483-
484- class Either (TraitType ):
485- """Defines a trait whose value can be any of of a specified list of traits."""
486-
487- def __init__ (self , * traits , ** metadata ):
488- """Create a trait whose value can be any of of a specified list of traits."""
489- _either_traits = tuple (trait_from (t ) for t in traits )
490- self .trait_maker = _TraitMaker (
491- metadata .pop ("default" , None ), * traits , ** metadata )
492- self .either_traits = _either_traits
471+ class Tuple (traits .Tuple ):
472+ pass
493473
494- def as_ctrait (self ):
495- """Return a CTrait corresponding to the trait defined by this class."""
496- return self .trait_maker .as_ctrait ()
497474
498- def inner_traits (self ):
499- """Return the *inner trait* (or traits) for this trait."""
500- return self .either_traits
475+ class Either (traits .Either ):
476+ pass
501477
502478
503479def _rebase_path (value , cwd ):
@@ -541,22 +517,22 @@ def _recurse_on_path_traits(func, thistrait, value, cwd):
541517
542518 value = [_recurse_on_path_traits (func , innertrait , v , cwd )
543519 for v in value ]
544- elif thistrait .is_trait_type (traits .Dict ):
520+ elif isinstance ( value , dict ) and thistrait .is_trait_type (traits .Dict ):
545521 _ , innertrait = thistrait .inner_traits
546522 value = {k : _recurse_on_path_traits (func , innertrait , v , cwd )
547523 for k , v in value .items ()}
548- elif thistrait .is_trait_type (Tuple ):
524+ elif isinstance ( value , tuple ) and thistrait .is_trait_type (Tuple ):
549525 value = tuple ([_recurse_on_path_traits (func , subtrait , v , cwd )
550- for subtrait , v in zip (thistrait .inner_traits , value )])
551- elif thistrait .is_trait_type (Either ):
552- is_str = [f . is_trait_type ( (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
553- for f in thistrait .inner_traits ]
526+ for subtrait , v in zip (thistrait .handler . types , value )])
527+ elif thistrait .is_trait_type (traits . TraitCompound ):
528+ is_str = [isinstance ( f , (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
529+ for f in thistrait .handler . handlers ]
554530 if any (is_str ) and isinstance (value , (bytes , str )) and not value .startswith ('/' ):
555531 return value
556- is_basepath = [ f . is_trait_type ( BasePath ) for f in thistrait . inner_traits ]
557- if any ( is_basepath ) :
558- subtrait = thistrait . inner_traits [ is_basepath . index ( True )]
559- value = _recurse_on_path_traits ( func , subtrait , value , cwd )
532+
533+ for subtrait in thistrait . handler . handlers :
534+ value = _recurse_on_path_traits ( func , subtrait (), value , cwd )
535+
560536 return value
561537
562538
0 commit comments