MCPcopy
hub / github.com/rocky/python-uncompyle6 / n_mkfunc_annotate

Function n_mkfunc_annotate

uncompyle6/semantics/customize3.py:289–334  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

287 self.n_call = n_call
288
289 def n_mkfunc_annotate(node):
290 # Handling EXTENDED_ARG before MAKE_FUNCTION ...
291 i = -1 if node[-2] == "EXTENDED_ARG" else 0
292
293 if self.version < (3, 3):
294 code_node = node[-2 + i]
295 elif self.version >= (3, 3) or node[-2] == "kwargs":
296 # LOAD_CONST code object ..
297 # LOAD_CONST 'x0' if >= 3.3
298 # EXTENDED_ARG
299 # MAKE_FUNCTION ..
300 code_node = node[-3 + i]
301 elif node[-3] == "expr":
302 code_node = node[-3][0]
303 else:
304 # LOAD_CONST code object ..
305 # MAKE_FUNCTION ..
306 code_node = node[-3]
307
308 self.indent_more()
309 for annotate_last in range(len(node) - 1, -1, -1):
310 if node[annotate_last] == "annotate_tuple":
311 break
312
313 # FIXME: the real situation is that when derived from
314 # function_def_annotate we the name has been filled in.
315 # But when derived from funcdefdeco it hasn't Would like a better
316 # way to distinguish.
317 if self.f.getvalue()[-4:] == "def ":
318 self.write(get_code_name(code_node.attr))
319
320 # FIXME: handle and pass full annotate args
321 make_function3_annotate(
322 self,
323 node,
324 is_lambda=False,
325 code_node=code_node,
326 annotate_last=annotate_last,
327 )
328
329 if len(self.param_stack) > 1:
330 self.write("\n\n")
331 else:
332 self.write("\n\n\n")
333 self.indent_less()
334 self.prune() # stop recursing
335
336 self.n_mkfunc_annotate = n_mkfunc_annotate
337

Callers

nothing calls this directly

Calls 5

get_code_nameFunction · 0.90
make_function3_annotateFunction · 0.90
indent_moreMethod · 0.80
indent_lessMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected