Skip to content

chore(repository): deprecate litestar.repository in favor of advanced_alchemy #4721

Description

@cofin

Summary

Convert every public symbol in litestar.repository.* into a thin deprecation shim that re-exports from advanced_alchemy.* and emits DeprecationWarning on access via PEP 562 module __getattr__. Internal Litestar callers (3 sites: 1 e2e test, 2 docs/examples) migrate to direct advanced_alchemy imports so the package does not warn against itself.

The custom tests/unit/test_repository/ directory is deleted — the abstract repository and the generic mock have no advanced_alchemy migration target, and rewriting 443 LOC of mock-repository tests against advanced_alchemy's testing utilities is out of scope. A new tests/unit/test_repository_deprecation.py asserts the deprecation warnings fire correctly across every public symbol.

This sets up the deprecation-then-removal pathway for the abstract repository module that PR #3299 originally proposed as a hard removal in 2024.

Out of scope (delegated to pre-ga-shim-removal)

  • git rm -r litestar/repository/ (whole module).
  • git rm -r docs/reference/repository/ (3 RSTs).
  • Stripping docs/conf.py lines 209-212 (litestar.repository.*.id_attribute PY_ATTR nitpick suppressions — they remain valid while the shims live).

Scope (this PR)

  • Migrate 3 in-tree call sites: tests/e2e/test_advanced_alchemy.py:4, docs/examples/sqla/sqlalchemy_repository_bulk_operations.py:10, docs/examples/sqla/sqlalchemy_sync_repository.py:24.
  • Add deprecation shims to: litestar/repository/__init__.py, exceptions.py, filters.py, handlers.py, abc/__init__.py, testing/__init__.py. Move handlers.py body to a private _handlers.py.
  • Rewrite 7 in-package internal cross-imports to use private modules (_filters, _exceptions, abc._async, abc._sync) so the package does not warn against itself.
  • Delete tests/unit/test_repository/ (4 files, 768 LOC).
  • Add tests/unit/test_repository_deprecation.py.
  • Add .. deprecated:: 3.0.0 directives to docs/reference/repository/{abc,handlers,testing}.rst.
  • Bootstrap docs/release-notes/migration_guide_3.rst with the deprecation table.
  • Append "Deprecated" entries to whats-new-3.rst and changelog.rst.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xThis is related to Litestar version 3Breaking 🔨RefactorThis is an improvement to existing code or configurationarea/contribThis PR involves changes to the contrib (Deprecated)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions