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

Function build_param

uncompyle6/semantics/make_function36.py:51–68  ·  view source on GitHub ↗

build parameters: - handle defaults - handle format tuple parameters

(ast, name, default, annotation=None)

Source from the content-addressed store, hash-verified

49 # Thank you, Python.
50
51 def build_param(ast, name, default, annotation=None):
52 """build parameters:
53 - handle defaults
54 - handle format tuple parameters
55 """
56 value = default
57 if annotation:
58 result = "%s: %s=%s" % (name, annotation, value)
59 else:
60 result = "%s=%s" % (name, value)
61
62 # The below can probably be removed. This is probably
63 # a holdover from days when LOAD_CONST erroneously
64 # didn't handle LOAD_CONST None properly
65 if result[-2:] == "= ": # default was 'LOAD_CONST None'
66 result += "None"
67
68 return result
69
70 # MAKE_FUNCTION_... or MAKE_CLOSURE_...
71 assert node[-1].kind.startswith("MAKE_")

Callers 1

make_function36Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected