@@ -468,36 +468,12 @@ class InputMultiObject(MultiObject):
468
468
OutputMultiPath = OutputMultiObject
469
469
470
470
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
493
473
494
- def as_ctrait (self ):
495
- """Return a CTrait corresponding to the trait defined by this class."""
496
- return self .trait_maker .as_ctrait ()
497
474
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
501
477
502
478
503
479
traits .Tuple = Tuple
@@ -545,22 +521,22 @@ def _recurse_on_path_traits(func, thistrait, value, cwd):
545
521
546
522
value = [_recurse_on_path_traits (func , innertrait , v , cwd )
547
523
for v in value ]
548
- elif thistrait .is_trait_type (traits .Dict ):
524
+ elif isinstance ( value , dict ) and thistrait .is_trait_type (traits .Dict ):
549
525
_ , innertrait = thistrait .inner_traits
550
526
value = {k : _recurse_on_path_traits (func , innertrait , v , cwd )
551
527
for k , v in value .items ()}
552
- elif thistrait .is_trait_type (Tuple ):
528
+ elif isinstance ( value , tuple ) and thistrait .is_trait_type (Tuple ):
553
529
value = tuple ([_recurse_on_path_traits (func , subtrait , v , cwd )
554
- for subtrait , v in zip (thistrait .inner_traits , value )])
555
- elif thistrait .is_trait_type (Either ):
556
- is_str = [f . is_trait_type ( (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
557
- for f in thistrait .inner_traits ]
530
+ for subtrait , v in zip (thistrait .handler . types , value )])
531
+ elif thistrait .is_trait_type (traits . TraitCompound ):
532
+ is_str = [isinstance ( f , (traits .String , traits .BaseStr , traits .BaseBytes , Str ))
533
+ for f in thistrait .handler . handlers ]
558
534
if any (is_str ) and isinstance (value , (bytes , str )) and not value .startswith ('/' ):
559
535
return value
560
- is_basepath = [ f . is_trait_type ( BasePath ) for f in thistrait . inner_traits ]
561
- if any ( is_basepath ) :
562
- subtrait = thistrait . inner_traits [ is_basepath . index ( True )]
563
- value = _recurse_on_path_traits ( func , subtrait , value , cwd )
536
+
537
+ for subtrait in thistrait . handler . handlers :
538
+ value = _recurse_on_path_traits ( func , subtrait (), value , cwd )
539
+
564
540
return value
565
541
566
542
0 commit comments