codegen-2 2.7.1__tar.gz → 2.7.2__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.7.1
3
+ Version: 2.7.2
4
4
  Summary: Meta-programming
5
5
  License: MIT
6
6
  Author: Binh Vu
@@ -100,7 +100,7 @@ class DefFuncStatement(Statement):
100
100
  sig = "async " + sig
101
101
  sig = sig + ":"
102
102
  if self.is_static:
103
- sig = "static " + sig
103
+ sig = "@staticmethod\n" + sig
104
104
  if self.comment != "":
105
105
  sig = (
106
106
  sig
@@ -185,6 +185,8 @@ class DefClassVarStatement(Statement):
185
185
  type: Optional[str]
186
186
  # value of the variable
187
187
  value: Optional[Expr] = None
188
+ # whether this variable is static
189
+ is_static: bool = False
188
190
 
189
191
  def to_python(self):
190
192
  if self.type is None:
@@ -196,10 +198,20 @@ class DefClassVarStatement(Statement):
196
198
  return f"{self.name}: {self.type} = {self.value.to_python()}"
197
199
 
198
200
  def to_typescript(self):
199
- assert self.type is not None
201
+ mod = ""
202
+ if self.is_static:
203
+ mod = "static "
204
+ else:
205
+ # static variable don't require type
206
+ assert self.type is not None
207
+ if self.type is not None:
208
+ type = f": {self.type}"
209
+ else:
210
+ type = ""
211
+
200
212
  if self.value is None:
201
- return f"{self.name}: {self.type};"
202
- return f"{self.name}: {self.type} = {self.value.to_typescript()};"
213
+ return f"{mod}{self.name}{type};"
214
+ return f"{mod}{self.name}{type} = {self.value.to_typescript()};"
203
215
 
204
216
 
205
217
  @dataclass
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codegen-2"
3
- version = "2.7.1"
3
+ version = "2.7.2"
4
4
  description = "Meta-programming"
5
5
  authors = ["Binh Vu <binh@toan2.com>"]
6
6
  license = "MIT"
File without changes
File without changes
File without changes