A typed workflow variable used in reads/writes/parameters.
| 57 | |
| 58 | @dataclass |
| 59 | class TypedVar: |
| 60 | """A typed workflow variable used in reads/writes/parameters.""" |
| 61 | name: str |
| 62 | base_type: str # e.g. "TString", "TList TUnknown" |
| 63 | value: Optional[object] = None # populated only for parameters |
| 64 | |
| 65 | def to_lean_typed(self) -> str: |
| 66 | parts = self.base_type.split() |
| 67 | lean_type = " .".join(parts) |
| 68 | return f'⟨"{self.name}", .{lean_type}⟩' |
| 69 | |
| 70 | def to_dict(self) -> dict: |
| 71 | d: dict = {"name": self.name, "base_type": self.base_type} |
| 72 | if self.value is not None: |
| 73 | d["value"] = self.value |
| 74 | return d |
| 75 | |
| 76 | @staticmethod |
| 77 | def from_dict(d: dict) -> "TypedVar": |
| 78 | return TypedVar(name=d["name"], base_type=d["base_type"], value=d.get("value")) |
| 79 | |
| 80 | |
| 81 | # ---------- NodeIR ---------- |
no outgoing calls
no test coverage detected