MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / _module_docstring

Function _module_docstring

applications/mapcoder/humaneval/dataset.py:123–138  ·  view source on GitHub ↗

Return the FIRST docstring found in the HumanEval prompt code. We use `ast` so multi-line strings inside the function are handled correctly. Return empty string if parsing fails or no docstring is found.

(prompt: str)

Source from the content-addressed store, hash-verified

121
122
123def _module_docstring(prompt: str) -> str:
124 """Return the FIRST docstring found in the HumanEval prompt code.
125
126 We use `ast` so multi-line strings inside the function are handled
127 correctly. Return empty string if parsing fails or no docstring is found.
128 """
129 try:
130 tree = ast.parse(prompt)
131 except SyntaxError:
132 return ""
133 for node in ast.walk(tree):
134 if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Module)):
135 doc = ast.get_docstring(node)
136 if doc:
137 return doc
138 return ""
139
140
141def _normalize_expected_repr(raw: str, entry_point: str) -> str:

Callers 1

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected