codegen-2 2.11.1__tar.gz → 2.12.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: codegen-2
3
- Version: 2.11.1
3
+ Version: 2.12.1
4
4
  Summary: Meta-programming
5
5
  License: MIT
6
6
  Author: Binh Vu
@@ -166,6 +166,6 @@ class ImportHelper:
166
166
  idents: dict[str, str] = field(default_factory=dict)
167
167
 
168
168
  def use(self, ident: str):
169
- assert ident in self.idents
169
+ assert ident in self.idents, ident
170
170
  self.program.import_(self.idents[ident], True)
171
171
  return ExprIdent(ident)
@@ -80,7 +80,7 @@ class ImportStatement(Statement):
80
80
  return f"import {{ {attr} as {self.alias} }} from '{module}';"
81
81
  return f"import {{ {attr} }} from '{module}';"
82
82
  else:
83
- raise NotImplementedError()
83
+ raise NotImplementedError(self)
84
84
 
85
85
 
86
86
  @dataclass
@@ -202,8 +202,8 @@ class DefClassVarStatement(Statement):
202
202
  if self.is_static:
203
203
  mod = "static "
204
204
  else:
205
- # static variable don't require type
206
- assert self.type is not None
205
+ # static variable don't require type, but non-static do
206
+ assert self.type is not None, self
207
207
  if self.type is not None:
208
208
  type = f": {self.type}"
209
209
  else:
@@ -214,6 +214,24 @@ class DefClassVarStatement(Statement):
214
214
  return f"{mod}{self.name}{type} = {self.value.to_typescript()};"
215
215
 
216
216
 
217
+ @dataclass
218
+ class DefEnumValueStatement(Statement):
219
+ """Statement to define an enum value"""
220
+
221
+ # name of the variable
222
+ name: str
223
+ # value of the variable
224
+ value: Optional[Expr] = None
225
+
226
+ def to_python(self):
227
+ raise NotImplementedError()
228
+
229
+ def to_typescript(self):
230
+ if self.value is None:
231
+ return f"{self.name},"
232
+ return f"{self.name} = {self.value.to_typescript()},"
233
+
234
+
217
235
  @dataclass
218
236
  class AssignStatement(Statement):
219
237
  var: Var | Expr
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codegen-2"
3
- version = "2.11.1"
3
+ version = "2.12.1"
4
4
  description = "Meta-programming"
5
5
  authors = ["Binh Vu <binh@toan2.com>"]
6
6
  license = "MIT"
File without changes
File without changes