@@ -240,7 +240,8 @@ def create_docstring(component_name, props, description):
240
240
241
241
Keyword arguments:\n {args}"""
242
242
).format (
243
- n = 'n' if component_name [0 ].lower () in ['a' , 'e' , 'i' , 'o' , 'u' ] else '' ,
243
+ n = 'n' if component_name [0 ].lower () in ['a' , 'e' , 'i' , 'o' , 'u' ]
244
+ else '' ,
244
245
name = component_name ,
245
246
description = description ,
246
247
args = '\n ' .join (
@@ -250,7 +251,8 @@ def create_docstring(component_name, props, description):
250
251
else prop ['flowType' ],
251
252
required = prop ['required' ],
252
253
description = prop ['description' ],
253
- default = prop ['defaultValue' ]['value' ] if 'defaultValue' in prop .keys () else '' ,
254
+ default = prop ['defaultValue' ]['value' ]
255
+ if 'defaultValue' in prop .keys () else '' ,
254
256
indent_num = 0 ,
255
257
is_flow_type = 'flowType' in prop and 'type' not in prop )
256
258
for p , prop in list (filter_props (props ).items ())))
@@ -429,27 +431,30 @@ def create_prop_docstring(prop_name, type_object, required, description,
429
431
is_required = 'optional'
430
432
if required :
431
433
is_required = 'required'
432
- elif len (default ) > 0 and 'null' not in str (default ) and '[]' not in str (default ):
433
- is_required = 'default {}' .format (default .replace ('\n ' , '\n ' + indent_spacing ))
434
+ elif default and 'null' not in str (default ) and '[]' not in str (default ):
435
+ is_required = 'default {}' .format (
436
+ default .replace ('\n ' , '\n ' + indent_spacing )
437
+ )
434
438
435
439
if '\n ' in py_type_name :
436
- return '{indent_spacing}- {name} (dict; {is_required}): {description}{period} ' \
437
- '{name} has the following type: {type}' .format (
438
- indent_spacing = indent_spacing ,
439
- name = prop_name ,
440
- type = py_type_name ,
441
- description = description ,
442
- period = '.' if len (description ) > 0 and description [- 1 ] != '.' else '' ,
443
- is_required = is_required )
440
+ return '{indent_spacing}- {name} (dict; {is_required}): ' \
441
+ '{description}{period} ' \
442
+ '{name} has the following type: {type}' .format (
443
+ indent_spacing = indent_spacing ,
444
+ name = prop_name ,
445
+ type = py_type_name ,
446
+ description = description ,
447
+ period = '.' if description and description [- 1 ] != '.' else '' ,
448
+ is_required = is_required )
444
449
return '{indent_spacing}- {name} ({type}' \
445
- '{is_required}){description}' .format (
446
- indent_spacing = indent_spacing ,
447
- name = prop_name ,
448
- type = '{}; ' .format (py_type_name ) if py_type_name else '' ,
449
- description = (
450
- ': {}' .format (description ) if description != '' else ''
451
- ),
452
- is_required = is_required )
450
+ '{is_required}){description}' .format (
451
+ indent_spacing = indent_spacing ,
452
+ name = prop_name ,
453
+ type = '{}; ' .format (py_type_name ) if py_type_name else '' ,
454
+ description = (
455
+ ': {}' .format (description ) if description != '' else ''
456
+ ),
457
+ is_required = is_required )
453
458
454
459
455
460
def map_js_to_py_types_prop_types (type_object ):
@@ -467,7 +472,8 @@ def shape_or_exact():
467
472
type_object = prop ,
468
473
required = prop ['required' ],
469
474
description = prop .get ('description' , '' ),
470
- default = prop ['defaultValue' ]['value' ] if 'defaultValue' in prop .keys () else '' ,
475
+ default = prop ['defaultValue' ]['value' ]
476
+ if 'defaultValue' in prop .keys () else '' ,
471
477
indent_num = 1
472
478
) for prop_name , prop in
473
479
list (type_object ['value' ].items ())))
@@ -558,6 +564,8 @@ def map_js_to_py_types_flow_types(type_object):
558
564
type_object = prop ['value' ],
559
565
required = prop ['value' ]['required' ],
560
566
description = prop ['value' ].get ('description' , '' ),
567
+ default = prop ['defaultValue' ]['value' ]
568
+ if 'defaultValue' in prop .keys () else '' ,
561
569
indent_num = indent_num ,
562
570
is_flow_type = True )
563
571
for prop in type_object ['signature' ]['properties' ]))),
@@ -590,7 +598,7 @@ def js_to_py_type(type_object, is_flow_type=False, indent_num=0):
590
598
if 'computed' in type_object and type_object ['computed' ] \
591
599
or type_object .get ('type' , '' ) == 'function' :
592
600
return ''
593
- elif js_type_name in js_to_py_types :
601
+ if js_type_name in js_to_py_types :
594
602
if js_type_name == 'signature' : # This is a Flow object w/ signature
595
603
return js_to_py_types [js_type_name ](indent_num )
596
604
# All other types
0 commit comments