Skip to content

Commit 370276f

Browse files
committed
Try ignoring the unused-ignore on py3.12
1 parent 05eed2a commit 370276f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pytensor/tensor/shape.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def c_code_cache_version(self):
147147
def shape(x: Union[np.ndarray, Number, Variable]) -> Variable:
148148
"""Return the shape of `x`."""
149149
if not isinstance(x, Variable):
150-
x = ptb.as_tensor_variable(x) # type: ignore
150+
# The following is a type error in Python 3.9 but not 3.12.
151+
# Thus we need to ignore unused-ignore on 3.12.
152+
x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore]
151153

152154
return cast(Variable, _shape(x))
153155

@@ -580,7 +582,9 @@ def specify_shape(
580582

581583
# If the specified shape is already encoded in the input static shape, do nothing
582584
# This ignores PyTensor constants in shape
583-
x = ptb.as_tensor_variable(x) # type: ignore
585+
x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore]
586+
# The above is a type error in Python 3.9 but not 3.12.
587+
# Thus we need to ignore unused-ignore on 3.12.
584588
new_shape_info = any(
585589
s != xts for (s, xts) in zip(shape, x.type.shape) if s is not None
586590
)

0 commit comments

Comments
 (0)