Skip to content

Drop GraphMatrixT export and make GraphPostprocessor a PEP 695 type alias#1223

Open
selmanozleyen wants to merge 1 commit into
scverse:mainfrom
selmanozleyen:refactor/pep695-drop-graphmatrixt
Open

Drop GraphMatrixT export and make GraphPostprocessor a PEP 695 type alias#1223
selmanozleyen wants to merge 1 commit into
scverse:mainfrom
selmanozleyen:refactor/pep695-drop-graphmatrixt

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

Follow-up to #1222. That PR deliberately left out two breaking changes (see its "Deliberately not done" section); now that the graph-builder API is still experimental, this applies both.

Changes

  • Drop GraphMatrixT from the public API. Removed from __all__ in squidpy.gr and squidpy.gr.neighbors, plus the two autosummary entries in docs/api.md. It was only exported to back the GraphPostprocessor alias.
  • Convert GraphPostprocessor to a PEP 695 type alias whose type parameter is scoped to the alias itself. This removes the now-unused module-level GraphMatrixT = TypeVar(...) and the TypeVar import.

Breaking changes

  • from squidpy.gr import GraphMatrixT (and from squidpy.gr.neighbors import GraphMatrixT) no longer works — the name is gone.
  • GraphPostprocessor's runtime type changes from a plain typing Callable form to TypeAliasType. Type-level usage (GraphPostprocessor[csr_matrix], annotations) is unchanged.

The GraphBuilder[CoordT, GraphMatrixT] class param and SpatialNeighborsResult[GraphMatrixT] are independent PEP 695 params and are unaffected.

Verification

  • ruff check src/squidpy/gr/ clean.
  • Runtime asserts: type(GraphPostprocessor).__name__ == "TypeAliasType", GraphPostprocessor[csr_matrix] still subscriptable, GraphMatrixT absent from both __all__s and no longer an attribute of squidpy.gr.neighbors.
  • tests/graph/test_spatial_neighbors.py: 50 passed.

🤖 Generated with Claude Code

…695 type alias

Follow-up to scverse#1222, which deliberately left these two breaking changes out.
Now that the graph-builder API is still experimental, apply both:

- Drop `GraphMatrixT` from `squidpy.gr` and `squidpy.gr.neighbors` `__all__`
  (and remove it from the autosummary in docs/api.md). It was only exported to
  back the `GraphPostprocessor` alias.
- Convert `GraphPostprocessor` to a PEP 695 `type` alias whose type parameter is
  scoped to the alias itself. This removes the now-unused module-level
  `GraphMatrixT`/`TypeVar`. Runtime type of `GraphPostprocessor` changes from a
  plain `typing` form to `TypeAliasType`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@selmanozleyen selmanozleyen added the release-breaking Breaking change (API or output behavior) label Jun 20, 2026
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.53%. Comparing base (9f9d500) to head (1768fa3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1223      +/-   ##
==========================================
- Coverage   76.53%   76.53%   -0.01%     
==========================================
  Files          63       63              
  Lines        9070     9069       -1     
  Branches     1523     1523              
==========================================
- Hits         6942     6941       -1     
  Misses       1544     1544              
  Partials      584      584              
Files with missing lines Coverage Δ
src/squidpy/gr/neighbors.py 90.74% <100.00%> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-breaking Breaking change (API or output behavior)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants