MCPcopy Create free account
hub / github.com/rocky/python-uncompyle6 / gen_function_parens_adjust

Function gen_function_parens_adjust

uncompyle6/semantics/helper.py:132–148  ·  view source on GitHub ↗

If we can avoid the outer parenthesis of a generator function, set the node key to 'call_generator' and the caller will do the default action on that. Otherwise we do nothing.

(mapping_key, node)

Source from the content-addressed store, hash-verified

130# Note: this is only used in Python > 3.0
131# Should move this somewhere more specific?
132def gen_function_parens_adjust(mapping_key, node):
133 """If we can avoid the outer parenthesis
134 of a generator function, set the node key to
135 'call_generator' and the caller will do the default
136 action on that. Otherwise we do nothing.
137 """
138 if mapping_key.kind != 'CALL_FUNCTION_1':
139 return
140
141 args_node = node[-2]
142 if args_node == 'pos_arg':
143 assert args_node[0] == 'expr'
144 n = args_node[0][0]
145 if n == 'generator_exp':
146 node.kind = 'call_generator'
147 pass
148 return
149
150def is_lambda_mode(compile_mode: str) -> bool:
151 return compile_mode in ("dictcomp", "genexpr", "lambda", "listcomp", "setcomp")

Callers 2

n_callFunction · 0.90
n_callFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected