diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc0e3f821c..0011c9714c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ jobs: if: ${{ needs.changes.outputs.changes == 'true' }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -70,7 +70,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.11"] + python-version: ["3.9", "3.12"] fast-compile: [0,1] float32: [0,1] install-numba: [0] @@ -101,7 +101,7 @@ jobs: float32: 0 part: "tests/link/numba" - install-numba: 1 - python-version: "3.11" + python-version: "3.11" # TODO: bump to 3.12 when numba 0.59 is released fast-compile: 0 float32: 0 part: "tests/link/numba" @@ -111,7 +111,7 @@ jobs: float32: 0 part: "tests/link/jax" - install-jax: 1 - python-version: "3.11" + python-version: "3.12" fast-compile: 0 float32: 0 part: "tests/link/jax" @@ -139,7 +139,7 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | - mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl "numpy<1.26" scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy + mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy # numba-scipy downgrades the installed scipy to 1.7.3 in Python 3.9, but # not numpy, even though scipy 1.7 requires numpy<1.23. When installing # PyTensor next, pip installs a lower version of numpy via the PyPI. @@ -249,7 +249,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 644453950f..faad0cd4bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: ruff-format args: ["--line-length=88"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.0.0 + rev: v1.8.0 hooks: - id: mypy language: python diff --git a/pyproject.toml b/pyproject.toml index 79610e64db..88689b20f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "pytensor" dynamic = ['version'] -requires-python = ">=3.9,<3.12" +requires-python = ">=3.9,<3.13" authors = [{ name = "pymc-devs", email = "pymc.devs@gmail.com" }] description = "Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs." readme = "README.rst" @@ -33,6 +33,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] keywords = [ diff --git a/pytensor/tensor/shape.py b/pytensor/tensor/shape.py index 75286b6690..cbf7192286 100644 --- a/pytensor/tensor/shape.py +++ b/pytensor/tensor/shape.py @@ -146,7 +146,9 @@ def c_code_cache_version(self): def shape(x: Union[np.ndarray, Number, Variable]) -> Variable: """Return the shape of `x`.""" if not isinstance(x, Variable): - x = ptb.as_tensor_variable(x) # type: ignore + # The following is a type error in Python 3.9 but not 3.12. + # Thus we need to ignore unused-ignore on 3.12. + x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore] return cast(Variable, _shape(x)) @@ -579,7 +581,9 @@ def specify_shape( # If the specified shape is already encoded in the input static shape, do nothing # This ignores PyTensor constants in shape - x = ptb.as_tensor_variable(x) # type: ignore + x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore] + # The above is a type error in Python 3.9 but not 3.12. + # Thus we need to ignore unused-ignore on 3.12. new_shape_info = any( s != xts for (s, xts) in zip(shape, x.type.shape) if s is not None )