Skip to content

Commit c0b1dfd

Browse files
committed
added Node typevar
1 parent ba56886 commit c0b1dfd

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

assets/logo_text.svg

Lines changed: 4 additions & 1 deletion
Loading

mtl/ast.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from collections import deque
3-
from typing import Union, NamedTuple
3+
from typing import Union, NamedTuple, TypeVar
44

55
import attr
66
import funcy as fn
@@ -9,6 +9,9 @@
99
from mtl import sugar
1010

1111

12+
Node = TypeVar("Node")
13+
14+
1215
def flatten_binary(phi, op, dropT, shortT):
1316
def f(x):
1417
return x.args if isinstance(x, op) else [x]
@@ -173,7 +176,7 @@ def __repr__(self):
173176
@ast_class
174177
class NaryOpMTL:
175178
OP = "?"
176-
args: "Node" # TODO: when 3.7 is more common replace with type union.
179+
args: Node # TODO: when 3.7 is more common replace with type union.
177180

178181
def __repr__(self):
179182
return "(" + f" {self.OP} ".join(f"{x}" for x in self.args) + ")"
@@ -191,7 +194,7 @@ class And(NaryOpMTL):
191194
class ModalOp:
192195
OP = '?'
193196
interval: Interval
194-
arg: "Node"
197+
arg: Node
195198

196199
def __repr__(self):
197200
if self.interval.lower == 0 and self.interval.upper == float('inf'):
@@ -209,8 +212,8 @@ class G(ModalOp):
209212

210213
@ast_class
211214
class WeakUntil:
212-
arg1: "Node"
213-
arg2: "Node"
215+
arg1: Node
216+
arg2: Node
214217

215218
def __repr__(self):
216219
return f"({self.arg1} W {self.arg2})"
@@ -222,7 +225,7 @@ def children(self):
222225

223226
@ast_class
224227
class Neg:
225-
arg: "Node"
228+
arg: Node
226229

227230
def __repr__(self):
228231
return f"~{self.arg}"
@@ -234,7 +237,7 @@ def children(self):
234237

235238
@ast_class
236239
class Next:
237-
arg: "Node"
240+
arg: Node
238241

239242
def __repr__(self):
240243
return f"X{self.arg}"

0 commit comments

Comments
 (0)