Fix: Python Enum types generate proper dropdown schemas with descriptions
Merged
AV
10mo ago+268+268+012345678901234567890123456789-26-26-01234567890123456789
Problem
Python scripts using Enum types don't generate proper UI dropdowns. Instead:
- Enum parameters show as generic text inputs (treated as
objecttype) - Docstring descriptions are ignored (all fields show empty
"") - Users must manually configure dropdowns for every enum parameter
class Color(str, Enum):
RED = 'red'
GREEN = 'green'
def main(color: Color = Color.RED):
"""
Args:
color (Color): Select a color
"""
pass
Current schema (broken):
{
"color": {
"type": "object",
"description": ""
}
}
Solution
Parse Enum class definitions and docstrings to generate proper schemas:
New schema (fixed):
{
"color": {
"type": "string",
"enum": ["red", "green", "blue"],
"description": "Select a color"
}
}
Changes
- Extract Enum class definitions and values from Python AST
- Parse docstring
Args:sections for parameter descriptions - Map Enum types to string enums instead of treating as resources
- Handle
Enum.VALUEdefault values correctly
Testing
Added test_parse_python_sig_enum covering all functionality. All tests pass.