fix(py-parser): read docstring Args descriptions for async def main
Merged
RU
4d ago+42+42+01234567890123456789-10-10-01234567890123456789
Summary
For a Python script whose entrypoint is async def main, the argument descriptions written in the docstring's Args: section were dropped from the inferred schema, while a plain def main got them. Redo of #12471 (thanks @hsusul).
Changes
filter_relevant_statementsalso keeps top-levelasync defblocks, so they reach the AST pass.extract_code_metadatareads the docstring ofmainwhether or not it is async.- When the line-based prefilter produces code that doesn't parse (a column-0 line inside a triple-quoted string, such as inline SQL, ends the block early), the metadata pass parses the full source instead of returning no metadata. Without this, keeping
async defblocks would have made such scripts lose their enum choices and defaults. - Regression test:
async def mainwith an enum argument, anArgs:docstring and a column-0 multiline string keeps its description, enum choices and default.
Test plan
-
cargo testinbackend/parsers/windmill-parser-py(37 passed) - New test fails on main and fails without the fallback; passes with both changes
š¤ Generated with Claude Code