|
38 | 38 | ConstantValue = Union[int, float, complex, str, bytes] |
39 | 39 | CONST_TYPES: Final = (int, float, complex, str, bytes) |
40 | 40 |
|
41 | | -E = TypeVar("E", Expression) |
| 41 | +Expr = TypeVar("Expr", Expression) |
42 | 42 |
|
43 | 43 |
|
44 | 44 | def constant_fold_expr(builder: IRBuilder, expr: Expression) -> ConstantValue | None: |
@@ -148,16 +148,16 @@ def try_constant_fold(builder: IRBuilder, expr: Expression) -> Value | None: |
148 | 148 |
|
149 | 149 |
|
150 | 150 | def folding_candidate( |
151 | | - transform: Callable[[IRBuilder, E], Value], |
152 | | -) -> Callable[[IRBuilder, E], Value]: |
| 151 | + transform: Callable[[IRBuilder, Expr], Value], |
| 152 | +) -> Callable[[IRBuilder, Expr], Value]: |
153 | 153 | """Mark a transform function as a candidate for constant folding. |
154 | 154 |
|
155 | 155 | Candidate functions will attempt to short-circuit the transformation |
156 | 156 | by constant folding the expression and will only proceed to transform |
157 | 157 | the expression if folding is not possible. |
158 | 158 | """ |
159 | 159 |
|
160 | | - def constant_fold_wrap(builder: IRBuilder, expr: E) -> Value: |
| 160 | + def constant_fold_wrap(builder: IRBuilder, expr: Expr) -> Value: |
161 | 161 | folded = try_constant_fold(builder, expr) |
162 | 162 | return folded if folded is not None else transform(builder, expr) |
163 | 163 |
|
|
0 commit comments