codegen-2 2.1.3__tar.gz → 2.1.4__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
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: codegen-2
3
- Version: 2.1.3
3
+ Version: 2.1.4
4
4
  Summary: Meta-programming
5
5
  License: MIT
6
6
  Author: Binh Vu
@@ -10,6 +10,7 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
13
14
  Description-Content-Type: text/markdown
14
15
 
15
16
  # codegen
@@ -8,6 +8,7 @@ from codegen.models.statement import (
8
8
  AssignStatement,
9
9
  BlockStatement,
10
10
  Comment,
11
+ DefClassStatement,
11
12
  DefFuncStatement,
12
13
  ElseStatement,
13
14
  ExceptionStatement,
@@ -91,6 +92,10 @@ class AST:
91
92
  )
92
93
  return self._add_stmt(DefFuncStatement(name, [var.get_var() for var in vars]))
93
94
 
95
+ def class_(self, name: str):
96
+ """Define a class."""
97
+ return self._add_stmt(DefClassStatement(name))
98
+
94
99
  def expr(self, expr: Expr):
95
100
  return self._add_stmt(SingleExprStatement(expr))
96
101
 
@@ -60,6 +60,14 @@ class DefFuncStatement(Statement):
60
60
  return f"def {self.name}({', '.join([arg.get_name() for arg in self.args])}):"
61
61
 
62
62
 
63
+ @dataclass
64
+ class DefClassStatement(Statement):
65
+ name: str
66
+
67
+ def to_python(self):
68
+ return f"class {self.name}:"
69
+
70
+
63
71
  @dataclass
64
72
  class AssignStatement(Statement):
65
73
  var: Var
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codegen-2"
3
- version = "2.1.3"
3
+ version = "2.1.4"
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