Files
midas/tests/cases/python-parser/03_functions.py.ref.json
LordBaryhobal 3de36e5bd5 feat: handle import statements
import statements now introduce variables with unknown types to avoid "Unknown variable" warnings
2026-07-06 15:21:56 +02:00

171 lines
3.7 KiB
JSON

{
"stmts": [
{
"_type": "FromImportStmt",
"module": "__future__",
"imports": [
{
"_type": "ImportAlias",
"name": "annotations",
"alias": null
}
],
"level": 0
},
{
"_type": "Function",
"name": "func",
"params": {
"_type": "ParamSpec",
"pos": [],
"mixed": [
{
"name": "col1",
"type": {
"_type": "BaseType",
"base": "Column",
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"args": []
},
"constraint": "0 <= _ <= 1"
}
]
},
"default": null
},
{
"name": "col2",
"type": {
"_type": "BaseType",
"base": "Column",
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"args": []
},
"constraint": "0 <= _ <= 1"
}
]
},
"default": null
}
],
"kw": []
},
"returns": {
"_type": "BaseType",
"base": "Column",
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"args": []
},
"constraint": "0 <= _ <= 2"
}
]
},
"body": [
{
"_type": "TypeAssign",
"name": "result",
"type": {
"_type": "BaseType",
"base": "Column",
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"args": []
},
"constraint": "0 <= _ <= 2"
}
]
}
},
{
"_type": "AssignStmt",
"targets": [
{
"_type": "VariableExpr",
"name": "result"
}
],
"value": {
"_type": "BinaryExpr",
"left": {
"_type": "VariableExpr",
"name": "col1"
},
"operator": "+",
"right": {
"_type": "VariableExpr",
"name": "col2"
}
}
},
{
"_type": "ReturnStmt",
"value": {
"_type": "VariableExpr",
"name": "result"
}
}
]
},
{
"_type": "Function",
"name": "func2",
"params": {
"_type": "ParamSpec",
"pos": [
{
"name": "a",
"type": {
"_type": "BaseType",
"base": "int",
"args": []
},
"default": null
}
],
"mixed": [
{
"name": "b",
"type": {
"_type": "BaseType",
"base": "float",
"args": []
},
"default": null
}
],
"kw": [
{
"name": "c",
"type": {
"_type": "BaseType",
"base": "str",
"args": []
},
"default": null
}
]
},
"returns": null,
"body": []
}
]
}