@@ -444,6 +444,7 @@ def generate_parser(toolparser, tool, namemap, records):
444
444
return toolparser
445
445
446
446
def generate_example_input (inptype ):
447
+ # type: (Union[Text, Dict[Text, Any]]) -> Any
447
448
defaults = { 'null' : 'null' ,
448
449
'Any' : 'null' ,
449
450
'boolean' : False ,
@@ -458,7 +459,7 @@ def generate_example_input(inptype):
458
459
'path' : 'default/directory/path' } }
459
460
if (not isinstance (inptype , str ) and
460
461
not isinstance (inptype , collections .Mapping )
461
- and isinstance (inptype , collections .Iterable )):
462
+ and isinstance (inptype , collections .MutableSet )):
462
463
if len (inptype ) == 2 and 'null' in inptype :
463
464
inptype .remove ('null' )
464
465
return generate_example_input (inptype [0 ])
@@ -467,7 +468,7 @@ def generate_example_input(inptype):
467
468
raise Exception ("multi-types other than optional not yet supported"
468
469
" for generating example input objects: %s"
469
470
% inptype )
470
- if 'type' in inptype :
471
+ if isinstance ( inptype , collections . Mapping ) and 'type' in inptype :
471
472
if inptype ['type' ] == 'array' :
472
473
return [ generate_example_input (inptype ['items' ]) ]
473
474
elif inptype ['type' ] == 'enum' :
@@ -476,9 +477,10 @@ def generate_example_input(inptype):
476
477
elif inptype ['type' ] == 'record' :
477
478
record = {}
478
479
for field in inptype ['fields' ]:
479
- record [shortname (field )] = generate_example_input (field )
480
+ record [shortname (field ['name' ])] = generate_example_input (
481
+ field ['type' ])
480
482
return record
481
- else :
483
+ elif isinstance ( inptype , str ) :
482
484
return defaults .get (inptype , 'custom_type' )
483
485
# TODO: support custom types, complex arrays
484
486
0 commit comments