Skip to content

refactor: centralize optional-dependency typing shims#717

Merged
cofin merged 0 commit intolitestar-org:feat/serializer-stufffrom
cofin:refactor/typing-shim-consolidation
Apr 26, 2026
Merged

refactor: centralize optional-dependency typing shims#717
cofin merged 0 commit intolitestar-org:feat/serializer-stufffrom
cofin:refactor/typing-shim-consolidation

Conversation

@cofin
Copy link
Copy Markdown
Member

@cofin cofin commented Apr 26, 2026

Summary

Centralizes every optional-dependency feature flag and stub type into a single canonical module, and enforces that internal code only imports from the public surface.

Stacked on top of #716 — diff will collapse to a single commit once that merges.

Changes

  • Make advanced_alchemy/_typing.py the single source of truth for all *_INSTALLED flags and optional-dependency stub types (pydantic, msgspec, attrs, cattrs, litestar, sqlmodel, numpy, orjson).
  • Re-export the full surface from the public advanced_alchemy/typing.py.
  • Delete advanced_alchemy/service/_typing.py — its contents were generic shims with nothing service-specific.
  • Update internal callers to import from advanced_alchemy.typing instead of reaching into private _typing modules.

Test plan

  • make lint passes
  • uv run pytest tests/unit -x -q passes
  • Public re-exports unchanged (from advanced_alchemy.service import ATTRS_INSTALLED still works)
  • CI green

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.55823% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.22%. Comparing base (8d61227) to head (f34718e).

Files with missing lines Patch % Lines
advanced_alchemy/utils/serialization.py 86.59% 22 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #717    +/-   ##
========================================
  Coverage   81.21%   81.22%            
========================================
  Files          99      100     +1     
  Lines        8300     8576   +276     
  Branches     1124     1160    +36     
========================================
+ Hits         6741     6966   +225     
- Misses       1232     1271    +39     
- Partials      327      339    +12     

☔ 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.

@cofin cofin changed the base branch from main to feat/serializer-stuff April 26, 2026 16:27
@cofin cofin force-pushed the refactor/typing-shim-consolidation branch from f34718e to 009edb1 Compare April 26, 2026 16:48
@cofin cofin merged commit 009edb1 into litestar-org:feat/serializer-stuff Apr 26, 2026
@cofin cofin force-pushed the feat/serializer-stuff branch from a53740c to e888e39 Compare April 26, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants