codegen-2 2.15.4__tar.gz → 2.15.6__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.4
2
2
  Name: codegen-2
3
- Version: 2.15.4
3
+ Version: 2.15.6
4
4
  Summary: Meta-programming
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -97,7 +97,7 @@ class AST:
97
97
  def func(
98
98
  self,
99
99
  name: str,
100
- vars: Sequence[DeferredVar | tuple[DeferredVar, Expr]],
100
+ vars: Sequence[Optional[DeferredVar] | tuple[DeferredVar, Expr]],
101
101
  return_type: Optional[Expr] = None,
102
102
  is_async: bool = False,
103
103
  is_static: bool = False,
@@ -107,6 +107,9 @@ class AST:
107
107
  """Define a function. The input variables are deferred vars as they are created for this function (i.e., must not be predefined prior to this function)"""
108
108
  grandchild_id = self.next_grandchild_id()
109
109
  for vararg in vars:
110
+ if vararg is None:
111
+ continue
112
+
110
113
  if isinstance(vararg, tuple):
111
114
  var = vararg[0]
112
115
  else:
@@ -127,6 +130,7 @@ class AST:
127
130
  else var.get_var()
128
131
  )
129
132
  for var in vars
133
+ if var is not None
130
134
  ],
131
135
  return_type,
132
136
  is_async,
@@ -173,9 +177,9 @@ class AST:
173
177
 
174
178
  def for_loop(self, item: DeferredVar, iter: Expr):
175
179
  """When we construct a for-loop, the item (or var) is always declared. We don't allow reassigning the variable in the for-loop."""
176
- assert (
177
- isinstance(item, DeferredVar) and item.has_not_been_created()
178
- ), "The item must be a new variable"
180
+ assert isinstance(item, DeferredVar) and item.has_not_been_created(), (
181
+ "The item must be a new variable"
182
+ )
179
183
  var = self.prog.create_var(
180
184
  item.name, item.key, self.next_grandchild_id(), item.force_name
181
185
  )
@@ -17,7 +17,7 @@ class Expr(ABC):
17
17
  raise NotImplementedError(self.__class__)
18
18
 
19
19
  def to_wrapped_python(self):
20
- if isinstance(self, (ExprVar, ExprConstant)):
20
+ if isinstance(self, (ExprVar, ExprConstant, ExprIdent)):
21
21
  return self.to_python()
22
22
  return f"({self.to_python()})"
23
23
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codegen-2"
3
- version = "2.15.4"
3
+ version = "2.15.6"
4
4
  description = "Meta-programming"
5
5
  authors = ["Binh Vu <binh@toan2.com>"]
6
6
  license = "MIT"
File without changes
File without changes