Skip to content

refactor(repository): migrate in-tree callers to advanced_alchemy.filters#4735

Merged
cofin merged 2 commits into
litestar-org:mainfrom
cofin:feat/repository-deprecation
Apr 26, 2026
Merged

refactor(repository): migrate in-tree callers to advanced_alchemy.filters#4735
cofin merged 2 commits into
litestar-org:mainfrom
cofin:feat/repository-deprecation

Conversation

@cofin

@cofin cofin commented Apr 26, 2026

Copy link
Copy Markdown
Member

Three call sites in tests and examples still imported LimitOffset from litestar.repository.filters even though advanced_alchemy.filters has been the canonical home for those types. This swaps the imports so the package is warning-free against itself, plus a small isort follow-up to keep the grouped advanced_alchemy imports tidy.

The deprecation shim that originally lived on this branch has been split out into a follow-up PR targeting v2 — that's where the DeprecationWarning belongs so 2.x users get a migration window before 3.0 GA removes the old path. This PR is now just the in-tree caller hygiene.


📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4735

@cofin
cofin requested review from a team as code owners April 26, 2026 15:15
@github-actions github-actions Bot added area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API area/repository size: medium pr/internal labels Apr 26, 2026
@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.38%. Comparing base (326e988) to head (883a58f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4735   +/-   ##
=======================================
  Coverage   67.38%   67.38%           
=======================================
  Files         292      292           
  Lines       14999    14999           
  Branches     1685     1685           
=======================================
  Hits        10107    10107           
  Misses       4756     4756           
  Partials      136      136           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cofin
cofin force-pushed the feat/repository-deprecation branch from ed051e5 to 9dec4bf Compare April 26, 2026 16:02
@github-actions github-actions Bot added size: small and removed area/private-api This PR involves changes to the privatized API area/repository size: medium labels Apr 26, 2026
@cofin cofin changed the title chore(repository): deprecate litestar.repository in favor of advanced_alchemy refactor(repository): migrate in-tree callers to advanced_alchemy.filters Apr 26, 2026
cofin added 2 commits April 26, 2026 11:06
Three call sites import LimitOffset from litestar.repository.filters; swap each
to advanced_alchemy.filters so the package is warning-free on a clean install
once the deprecation shims land in the next commit.
@cofin
cofin force-pushed the feat/repository-deprecation branch from 9dec4bf to 883a58f Compare April 26, 2026 18:06
@cofin
cofin merged commit f4d351f into litestar-org:main Apr 26, 2026
25 checks passed
cofin added a commit that referenced this pull request May 11, 2026
…ns.minijinja (#4760)

Moves the MiniJinja template engine integration from `litestar.contrib.minijinja` to `litestar.plugins.minijinja`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim covering both public and private symbols. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758).

`litestar/plugins/flash.py` lazily imports the private `_transform_state` from MiniJinja, so any deprecation shim has to forward private symbols. That diagnosis came from @xronocode's audit in #4754; this PR preserves it by migrating flash.py before deleting contrib, so every intermediate commit keeps the dependency graph valid.

Salvages the contrib tests into `tests/unit/test_plugins/test_minijinja.py` (98% coverage), migrates every internal call site, and adds `docs/reference/plugins/minijinja.rst`.

Closes #4718.

Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin added a commit that referenced this pull request May 11, 2026
…4764)

Moves the Mako template engine integration from `litestar.contrib.mako` to `litestar.plugins.mako`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim, giving 2.x users a migration window. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758).

Implementation reference: PR #4753 by @xronocode. Every commit carries a co-author trailer.

Salvages the contrib tests into `tests/unit/test_plugins/test_mako.py`, migrates every internal call site (csrf middleware, flash, template suite), and adds `docs/reference/plugins/mako.rst`.

Closes #4717.

Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin added a commit that referenced this pull request May 13, 2026
…#4762)

Moves the Jinja2 template engine integration from `litestar.contrib.jinja` to `litestar.plugins.jinja`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim, giving 2.x users a migration window. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758).

Implementation reference: PR #4752 by @xronocode. Every commit carries a co-author trailer.

Salvages the contrib tests into `tests/unit/test_plugins/test_jinja.py`, migrates every internal call site (csrf middleware, flash, template suite, htmx examples), and adds `docs/reference/plugins/jinja.rst`.

Closes #4716.

Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin added a commit that referenced this pull request May 17, 2026
This deprecates `litestar.repository` in favor of `advanced_alchemy`. The `litestar.repository` module — including its `filters`, `exceptions`, `handlers`, `abc`, and `testing` submodules — will be removed before 3.0.0, and this lands the deprecation on the v2 line so users have a release to migrate against.

The new home for everything is `advanced_alchemy`:

- `advanced_alchemy.filters` for the filter types
- `advanced_alchemy.exceptions` for the repository exceptions
- `advanced_alchemy.repository.SQLAlchemyAsyncRepository` / `SQLAlchemySyncRepository` for the abstract base classes
- `advanced_alchemy.repository.memory.SQLAlchemyAsyncMockRepository` / `SQLAlchemySyncMockRepository` for the generic mock under `litestar.repository.testing`

Each public symbol's warning text spells out exactly what to import instead, so users get a one-line fix from the `DeprecationWarning` itself.

Under the hood this is PEP 562 `__getattr__` shims at every submodule entry point. Importing `litestar.repository` is silent; only attribute access fires the warning, so test runs that touch the package transitively don't get spammed.

Documentation gets a `.. deprecated:: 2.22.0` notice on each of the three reference pages, and there's a changelog entry under a new `2.22.0` block. A parametrized test in `tests/unit/test_deprecations.py` asserts every public symbol fires `DeprecationWarning` and that the message names the `advanced_alchemy` target.

### Note on `nitpick_ignore`

The deprecation notes cross-reference `advanced_alchemy` classes via `:class:` directives. Those can't be resolved through intersphinx right now — advanced-alchemy's `objects.inv` is missing `py:class` entries for everything under `advanced_alchemy.repository` and `advanced_alchemy.repository.memory` (only `py:parameter` entries are indexed). Filed upstream as [advanced-alchemy#729](litestar-org/advanced-alchemy#729).

As a temporary workaround, this PR adds three entries to `nitpick_ignore` in `docs/conf.py`, matching the existing entry for `SQLAlchemyAsyncRepository`:

- `advanced_alchemy.repository.SQLAlchemySyncRepository`
- `advanced_alchemy.repository.memory.SQLAlchemyAsyncMockRepository`
- `advanced_alchemy.repository.memory.SQLAlchemySyncMockRepository`

Once the upstream fix ships and the v3.x line picks up the new inventory, those entries can be removed.

Closes #4721 once merged. The main-side migration of in-tree callers landed in #4735.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs This PR involves changes to the documentation pr/internal size: small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants