Compare commits

...

3 Commits

Author SHA1 Message Date
16239db479 feat(gen): add tuple expr to generator 2026-06-29 22:44:39 +02:00
dc2134c87d tests: update with multi-parameter generics 2026-06-29 22:43:08 +02:00
89f3c945e4 fix: minor fixes 2026-06-29 22:41:47 +02:00
8 changed files with 92 additions and 72 deletions

View File

@@ -1233,7 +1233,7 @@ class PythonTyper(
node: ast.Expression = ast.parse(value, mode="eval")
return parser._parse_type(node.body)
case p.VariableExpr(name=name):
return p.BaseType(location=location, base=name, param=None)
return p.BaseType(location=location, base=name, args=())
case _:
raise NotImplementedError

View File

@@ -196,6 +196,11 @@ class Generator(p.Stmt.Visitor[ast.stmt], p.Expr.Visitor[ast.expr]):
step=expr.step.accept(self) if expr.step is not None else None,
)
def visit_tuple_expr(self, expr: p.TupleExpr) -> ast.expr:
return ast.Tuple(
elts=[item.accept(self) for item in expr.items],
)
def visit_raw_expr(self, expr: p.RawExpr) -> ast.expr:
return expr.expr

View File

@@ -24,7 +24,7 @@
"type": {
"_type": "BaseType",
"base": "Meter",
"param": null
"args": []
},
"expr": {
"_type": "LiteralExpr",
@@ -62,7 +62,7 @@
"type": {
"_type": "BaseType",
"base": "Second",
"param": null
"args": []
},
"expr": {
"_type": "LiteralExpr",

View File

@@ -317,7 +317,7 @@
"pos": 0,
"name": "object",
"type": {},
"required": true
"required": false
}
],
"args": [],

View File

@@ -16,7 +16,7 @@
"type": {
"_type": "BaseType",
"base": "bool",
"param": null
"args": []
}
},
{
@@ -25,7 +25,7 @@
"type": {
"_type": "BaseType",
"base": "int",
"param": null
"args": []
}
},
{
@@ -36,7 +36,7 @@
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "(_ > 0) + (_ < 250)"
}
@@ -47,7 +47,7 @@
"type": {
"_type": "BaseType",
"base": "str",
"param": null
"args": []
}
},
{
@@ -56,7 +56,7 @@
"type": {
"_type": "BaseType",
"base": "datetime",
"param": null
"args": []
}
},
{
@@ -65,7 +65,7 @@
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
}
},
{
@@ -79,7 +79,7 @@
"type": {
"_type": "BaseType",
"base": "_",
"param": null
"args": []
}
}
]

View File

@@ -16,7 +16,7 @@
"type": {
"_type": "BaseType",
"base": "GeoLocation",
"param": null
"args": []
}
}
]
@@ -28,11 +28,13 @@
"type": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "BaseType",
"base": "GeoLocation",
"param": null
"args": []
}
]
}
},
{
@@ -65,11 +67,13 @@
"type": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "BaseType",
"base": "GeoLocation",
"param": null
"args": []
}
]
}
},
{
@@ -117,7 +121,7 @@
"type": {
"_type": "BaseType",
"base": "Latitude",
"param": null
"args": []
}
},
{
@@ -146,7 +150,7 @@
"type": {
"_type": "BaseType",
"base": "Latitude",
"param": null
"args": []
}
},
{
@@ -175,11 +179,13 @@
"type": {
"_type": "BaseType",
"base": "Difference",
"param": {
"args": [
{
"_type": "BaseType",
"base": "Latitude",
"param": null
"args": []
}
]
}
},
{
@@ -217,7 +223,7 @@
"type": {
"_type": "BaseType",
"base": "int",
"param": null
"args": []
},
"constraint": "_ >= 0"
}
@@ -230,7 +236,7 @@
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "_ >= 0"
}
@@ -252,7 +258,7 @@
"type": {
"_type": "BaseType",
"base": "int",
"param": null
"args": []
},
"constraint": "Positive"
}
@@ -265,7 +271,7 @@
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "Positive"
}

View File

@@ -14,15 +14,17 @@
"type": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "0 <= _ <= 1"
}
]
},
"default": null
},
@@ -31,15 +33,17 @@
"type": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "0 <= _ <= 1"
}
]
},
"default": null
}
@@ -50,15 +54,17 @@
"returns": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "0 <= _ <= 2"
}
]
},
"body": [
{
@@ -67,15 +73,17 @@
"type": {
"_type": "BaseType",
"base": "Column",
"param": {
"args": [
{
"_type": "ConstraintType",
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"constraint": "0 <= _ <= 2"
}
]
}
},
{
@@ -117,7 +125,7 @@
"type": {
"_type": "BaseType",
"base": "int",
"param": null
"args": []
},
"default": null
}
@@ -128,7 +136,7 @@
"type": {
"_type": "BaseType",
"base": "float",
"param": null
"args": []
},
"default": null
}
@@ -140,7 +148,7 @@
"type": {
"_type": "BaseType",
"base": "str",
"param": null
"args": []
},
"default": null
}

View File

@@ -30,6 +30,7 @@ from midas.ast.python import (
Stmt,
SubscriptExpr,
TernaryExpr,
TupleExpr,
TypeAssign,
UnaryExpr,
VariableExpr,