From 5f5ccc2a09d43313433a6b2974da8298c0a1a1f0 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 25 Sep 2026 15:33:43 +0200 Subject: [PATCH 1/3] chore: clean up stubs --- typings/llvmlite/__init__.pyi | 1 - typings/numba/__init__.pyi | 38 ++--------------------- typings/numba/core/base.pyi | 2 -- typings/numba/core/datamodel/__init__.pyi | 2 -- typings/numba/core/datamodel/manager.pyi | 2 -- typings/numba/core/datamodel/registry.pyi | 6 ---- typings/numba/core/typing/templates.pyi | 5 --- typings/numba/core/typing/typeof.pyi | 15 --------- typings/numba/extending.pyi | 2 -- 9 files changed, 3 insertions(+), 70 deletions(-) delete mode 100644 typings/llvmlite/__init__.pyi delete mode 100644 typings/numba/core/base.pyi delete mode 100644 typings/numba/core/datamodel/__init__.pyi delete mode 100644 typings/numba/core/datamodel/manager.pyi delete mode 100644 typings/numba/core/datamodel/registry.pyi delete mode 100644 typings/numba/core/typing/templates.pyi delete mode 100644 typings/numba/core/typing/typeof.pyi delete mode 100644 typings/numba/extending.pyi diff --git a/typings/llvmlite/__init__.pyi b/typings/llvmlite/__init__.pyi deleted file mode 100644 index a830806d..00000000 --- a/typings/llvmlite/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 diff --git a/typings/numba/__init__.pyi b/typings/numba/__init__.pyi index f5299479..6eb44a65 100644 --- a/typings/numba/__init__.pyi +++ b/typings/numba/__init__.pyi @@ -1,42 +1,10 @@ # SPDX-License-Identifier: MPL-2.0 -from collections.abc import Callable, Iterable -from typing import Literal, SupportsIndex, overload +from collections.abc import Iterable +from typing import SupportsIndex, overload from .core import config as config -from .core.types import Type +from .core.decorators import njit as njit -type __Signature = str | Type -type _Signature = str | Type | tuple[__Signature, ...] - -# https://numba.readthedocs.io/en/stable/reference/jit-compilation.html#numba.jit -@overload -def njit[F: Callable[..., object]]( - f: F, - *, - nopython: bool = True, - nogil: bool = False, - cache: bool = False, - forceobj: bool = False, - parallel: bool = False, - error_model: Literal["python", "numpy"] = "python", - fastmath: bool = False, - locals: dict[str, object] = {}, - boundscheck: bool = False, -) -> F: ... -@overload -def njit[F: Callable[..., object]]( - signature: _Signature | list[_Signature] | None = None, - *, - nopython: bool = True, - nogil: bool = False, - cache: bool = False, - forceobj: bool = False, - parallel: bool = False, - error_model: Literal["python", "numpy"] = "python", - fastmath: bool = False, - locals: dict[str, object] = {}, - boundscheck: bool = False, -) -> Callable[[F], F]: ... @overload def prange(stop: SupportsIndex, /) -> Iterable[int]: ... @overload diff --git a/typings/numba/core/base.pyi b/typings/numba/core/base.pyi deleted file mode 100644 index d2c09a21..00000000 --- a/typings/numba/core/base.pyi +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -class BaseContext: ... diff --git a/typings/numba/core/datamodel/__init__.pyi b/typings/numba/core/datamodel/__init__.pyi deleted file mode 100644 index c93e572a..00000000 --- a/typings/numba/core/datamodel/__init__.pyi +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -from .registry import register_default as register_default diff --git a/typings/numba/core/datamodel/manager.pyi b/typings/numba/core/datamodel/manager.pyi deleted file mode 100644 index dc5bfeb1..00000000 --- a/typings/numba/core/datamodel/manager.pyi +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -class DataModelManager: ... diff --git a/typings/numba/core/datamodel/registry.pyi b/typings/numba/core/datamodel/registry.pyi deleted file mode 100644 index d15ce3bf..00000000 --- a/typings/numba/core/datamodel/registry.pyi +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -from collections.abc import Callable - -from ..types import Type - -def register_default[F: Callable[..., object]](typecls: type[Type]) -> Callable[[F], F]: ... diff --git a/typings/numba/core/typing/templates.pyi b/typings/numba/core/typing/templates.pyi deleted file mode 100644 index 9dd8fa96..00000000 --- a/typings/numba/core/typing/templates.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -from numba.core.types import Type - -class Signature: - return_type: Type diff --git a/typings/numba/core/typing/typeof.pyi b/typings/numba/core/typing/typeof.pyi deleted file mode 100644 index e18e8cb6..00000000 --- a/typings/numba/core/typing/typeof.pyi +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -from enum import Enum -from functools import singledispatch - -from numba.core.types import Type - -class Purpose(Enum): - argument = 1 - constant = 2 - -class _TypeofContext: - purpose: Purpose - -@singledispatch -def typeof_impl(val: object, c: _TypeofContext) -> Type: ... diff --git a/typings/numba/extending.pyi b/typings/numba/extending.pyi deleted file mode 100644 index 8a4da9ac..00000000 --- a/typings/numba/extending.pyi +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -from .core.extending import * From 1847d9be485351b9ddc85a623c3f5bfa6dd1b906 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 25 Sep 2026 15:43:46 +0200 Subject: [PATCH 2/3] ci: autofix --- .github/dependabot.yml | 11 +++++++++++ .github/workflows/autofix.yml | 26 ++++++++++++++++++++++++++ .github/workflows/ci-gpu.yml | 2 +- .github/workflows/ci.yml | 10 ---------- .pre-commit-config.yaml | 35 ++++++++++++----------------------- pyproject.toml | 16 ++++++++++++++++ 6 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/autofix.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3ab6b30e..c6588f68 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,16 @@ version: 2 updates: + - package-ecosystem: pre-commit + directory: / + labels: + - run-gpu-ci + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + pre-commit: + patterns: ["*"] - package-ecosystem: github-actions directory: / labels: diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml new file mode 100644 index 00000000..86bf96cb --- /dev/null +++ b/.github/workflows/autofix.yml @@ -0,0 +1,26 @@ +# The workflow name is mandated by autofix.ci. +# It needs to be a dedicated workflow, as autofix.ci times out on long runs. +name: autofix.ci + +on: + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + name: Pre-commit checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: { fetch-depth: 0, filter: "blob:none", persist-credentials: false } + - uses: astral-sh/setup-uv@v10.1.0 + with: + enable-cache: true + - run: uv tool install hatch + - name: Run pre-commit hooks + run: uvx prek run --all-files --show-diff-on-failure --color=always + - uses: autofix-ci/action@v1.3.4 + if: '!cancelled()' diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 972f75aa..d89d00ee 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -25,7 +25,7 @@ jobs: steps: - uses: flying-sheep/check@v1 with: - success: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-gpu-ci') || github.event.pull_request.user.login == 'pre-commit-ci[bot]' }} + success: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-gpu-ci') }} test: name: All Tests needs: check diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bcedb97..ba04d644 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,15 +106,6 @@ jobs: - run: python -c 'import fast_array_utils as fau; print(fau.__all__)' - run: uv pip install --system -e .[testing] - run: python -c 'import testing.fast_array_utils as tfau; print(tfau.ArrayType("numpy", "ndarray"))' - check: - name: Static Checks - runs-on: ubuntu-latest - env: - SKIP: no-commit-to-branch # this CI runs on the main branch - steps: - - uses: actions/checkout@v7 - with: { fetch-depth: 0, filter: "blob:none" } - - uses: j178/prek-action@v3.0.0 pass: name: All Checks if: always() @@ -123,7 +114,6 @@ jobs: - test - bench - import - - check runs-on: ubuntu-latest steps: - uses: re-actors/alls-green@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d9b8b9f..75f39f1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,9 @@ repos: rev: v6.0.0 hooks: - id: end-of-file-fixer + groups: [format] - id: trailing-whitespace + groups: [format] - id: no-commit-to-branch - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.16.8 @@ -13,37 +15,24 @@ repos: - id: ruff-check args: [--preview, --select=CPY] - id: ruff-format + groups: [format] - repo: https://github.com/tox-dev/pyproject-fmt rev: v2.29.4 hooks: - id: pyproject-fmt + groups: [format] - repo: https://github.com/biomejs/pre-commit rev: v2.5.14 hooks: - id: biome-format -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v2.3.1 + groups: [format] +- repo: local hooks: - id: mypy - args: [--config-file=pyproject.toml, .] + name: mypy + entry: hatch check types + language: system + types_or: [python, pyi] + require_serial: true pass_filenames: false - additional_dependencies: - - anndata>=0.12 - - array-api-compat>=1.13,!=1.15.0 # https://github.com/data-apis/array-api-compat/issues/436 - - dask>=2026.1 - - h5py>=3.15 - - jax>=0.10 - - numba>=0.63 - - packaging>=26 - - pytest>=9 - - pytest-codspeed>=4.3 - - scikit-learn>=1.8 - - scipy-stubs>=1.17 - - sphinx>=9 - - types-array-api>=1.3 - - types-docutils>=0.22 - - zarr>=3.1 -ci: - autoupdate_commit_msg: 'ci: pre-commit autoupdate' - skip: - - mypy # too big + groups: [typecheck] diff --git a/pyproject.toml b/pyproject.toml index 27f8eb9e..cc8e1dff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,12 @@ test-min = [ "pytest-doctestplus", "pytest-xdist", ] +typecheck = [ + "array-api-compat!=1.15", # https://github.com/data-apis/array-api-compat/issues/436 + "mypy", + "scipy-stubs", + "sphinx", +] [tool.hatch] version.source = "vcs" @@ -75,6 +81,15 @@ envs.docs.scripts.build = "sphinx-build -M html docs docs/_build" envs.docs.scripts.clean = "git clean -fdX docs" envs.docs.scripts.open = "python -m webbrowser -t docs/_build/html/index.html" envs.docs.dependency-groups = [ "doc" ] +envs.hatch-check-code.dependencies = [ "prek" ] +envs.hatch-check-code.scripts.lint-check = "echo 'try `hatch check code --fix`'; false" +envs.hatch-check-code.scripts.lint-fix = "prek run -a --no-group=format --no-group=typecheck" +envs.hatch-check-fmt.dependencies = [ "prek" ] +envs.hatch-check-fmt.scripts.format-check = "echo 'try `hatch check fmt --fix`'; false" +envs.hatch-check-fmt.scripts.format-fix = "prek run -a --group=format --no-group=typecheck" +envs.hatch-check-types.features = [ "full" ] # the `test` group’s self-reference doesn’t get the extras +envs.hatch-check-types.scripts.check = [ "mypy" ] +envs.hatch-check-types.dependency-groups = [ "typecheck", "test" ] envs.hatch-test.extra-dependencies = [ "ipycytoscape", "ipykernel" ] envs.hatch-test.env-vars.CODSPEED_PROFILE_FOLDER = "test-data/codspeed" envs.hatch-test.matrix = [ @@ -140,6 +155,7 @@ lint.future-annotations = true [tool.mypy] mypy_path = [ "$MYPY_CONFIG_FILE_DIR/typings", "$MYPY_CONFIG_FILE_DIR/src" ] +files = [ "." ] explicit_package_bases = true # https://github.com/dask/dask/issues/8853 implicit_reexport = true From 42f7300f16a045291290a26d278ac2a2bd8619d3 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 25 Sep 2026 15:57:12 +0200 Subject: [PATCH 3/3] fix --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cc8e1dff..8b5fb1a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,6 @@ envs.hatch-check-code.scripts.lint-fix = "prek run -a --no-group=format --no-gro envs.hatch-check-fmt.dependencies = [ "prek" ] envs.hatch-check-fmt.scripts.format-check = "echo 'try `hatch check fmt --fix`'; false" envs.hatch-check-fmt.scripts.format-fix = "prek run -a --group=format --no-group=typecheck" -envs.hatch-check-types.features = [ "full" ] # the `test` group’s self-reference doesn’t get the extras envs.hatch-check-types.scripts.check = [ "mypy" ] envs.hatch-check-types.dependency-groups = [ "typecheck", "test" ] envs.hatch-test.extra-dependencies = [ "ipycytoscape", "ipykernel" ]