#NEWLINE# def detectFunctionBodyKind( nodes ) : #NEWLINE# #INDENT# indications = set ( ) #NEWLINE# written_variables = set ( ) #NEWLINE# non_local_declarations = set ( ) #NEWLINE# global_declarations = set ( ) #NEWLINE# flags = set ( ) #NEWLINE# def _check( node ) : #NEWLINE# #INDENT# node_class = node . __class__ #NEWLINE# if ( node_class is ast . Yield ) : #NEWLINE# #INDENT# indications . add ( 'Generator' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( python_version >= 330 ) and ( node_class is ast . YieldFrom ) ) : #NEWLINE# #INDENT# indications . add ( 'Generator' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( python_version >= 350 ) and ( node_class in ( ast . Await , ast . AsyncWith ) ) ) : #NEWLINE# #INDENT# indications . add ( 'Coroutine' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( node_class is ast . Assign ) : #NEWLINE# #INDENT# for target in node . targets : #NEWLINE# #INDENT# if ( type ( target ) is str ) : #NEWLINE# #INDENT# written_variables . add ( target ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( target . __class__ is ast . Name ) : #NEWLINE# #INDENT# written_variables . add ( target . id ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( python_version >= 300 ) and ( node_class is ast . Nonlocal ) ) : #NEWLINE# #INDENT# non_local_declarations . update ( set ( node . names ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( node_class is ast . Global ) : #NEWLINE# #INDENT# global_declarations . update ( set ( node . names ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( node_class is ast . ClassDef ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name in ( 'bases' , 'decorator_list' , 'keywords' ) ) : #NEWLINE# #INDENT# for child in field : #NEWLINE# #INDENT# _check ( child ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'starargs' ) : #NEWLINE# #INDENT# if ( field is not None ) : #NEWLINE# #INDENT# _check ( field ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'kwargs' ) : #NEWLINE# #INDENT# if ( field is not None ) : #NEWLINE# #INDENT# _check ( field ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( node_class in ( ast . FunctionDef , ast . Lambda ) ) or ( ( python_version >= 350 ) and ( node_class is ast . AsyncFunctionDef ) ) ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name in ( 'bases' , 'decorator_list' ) ) : #NEWLINE# #INDENT# for child in field : #NEWLINE# #INDENT# _check ( child ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'args' ) : #NEWLINE# #INDENT# for child in field . defaults : #NEWLINE# #INDENT# _check ( child ) #NEWLINE# #UNINDENT# if ( python_version >= 300 ) : #NEWLINE# #INDENT# for child in node . args . kw_defaults : #NEWLINE# #INDENT# if ( child is not None ) : #NEWLINE# #INDENT# _check ( child ) #NEWLINE# #UNINDENT# #UNINDENT# for child in node . args . args : #NEWLINE# #INDENT# if ( child . annotation is not None ) : #NEWLINE# #INDENT# _check ( child . annotation ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'returns' ) : #NEWLINE# #INDENT# if ( field is not None ) : #NEWLINE# #INDENT# _check ( field ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( node_class is ast . GeneratorExp ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' , 'comparators' , 'elt' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'generators' ) : #NEWLINE# #INDENT# _check ( field [ 0 ] . iter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( node_class is ast . ListComp ) and ( python_version >= 300 ) ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' , 'comparators' , 'elt' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'generators' ) : #NEWLINE# #INDENT# _check ( field [ 0 ] . iter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( python_version >= 270 ) and ( node_class is ast . SetComp ) ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' , 'comparators' , 'elt' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'generators' ) : #NEWLINE# #INDENT# _check ( field [ 0 ] . iter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( python_version >= 270 ) and ( node_class is ast . DictComp ) ) : #NEWLINE# #INDENT# for ( name , field ) in ast . iter_fields ( node ) : #NEWLINE# #INDENT# if ( name in ( 'name' , 'body' , 'comparators' , 'key' , 'value' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'generators' ) : #NEWLINE# #INDENT# _check ( field [ 0 ] . iter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( name , field , ast . dump ( node ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( node_class is ast . Name ) : #NEWLINE# #INDENT# if ( ( python_version >= 300 ) and ( node . id == 'super' ) ) : #NEWLINE# #INDENT# flags . add ( 'has_super' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for child in ast . iter_child_nodes ( node ) : #NEWLINE# #INDENT# _check ( child ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for node in nodes : #NEWLINE# #INDENT# _check ( node ) #NEWLINE# #UNINDENT# if indications : #NEWLINE# #INDENT# assert ( len ( indications ) == 1 ) #NEWLINE# function_kind = indications . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# function_kind = 'Function' #NEWLINE# #UNINDENT# return ( function_kind , flags , written_variables , non_local_declarations , global_declarations )