Add deprecation shims for bundled_libraries module globals
Merged
MA
2mo ago+121+121+012345678901234567890123456789-3-3-0123456789
Type of change
- Bug fix (non-breaking change which fixes an issue)
- This change requires a documentation update
Description
Adds compatibility shims to maintain backward compatibility with downstream packages (notably reflex-enterprise) that read reflex_base.components.dynamic.bundled_libraries and DEFAULT_BUNDLED_LIBRARIES directly.
These module-level globals were moved onto RegistrationContext in a prior breaking change. This PR restores read access to them via __getattr__ hooks that:
- Resolve against the active
RegistrationContextwhen accessed - Emit deprecation warnings (removal in 1.0) directing users to the new API
- Properly propagate
AttributeErrorfor unknown attributes
The shims are implemented in:
reflex_base.components.dynamic.__getattr__()— handles the actual resolutionreflex/components/dynamic.__getattr__()— delegates to reflex_base for names the star import misses
Changes
- reflex_base/components/dynamic.py: Added
__getattr__()to provide deprecated access tobundled_librariesandDEFAULT_BUNDLED_LIBRARIES, resolving them against the active context with deprecation warnings - reflex/components/dynamic.py: Added
__getattr__()to delegate attribute lookups to reflex_base (needed because star imports don't trigger__getattr__) - tests/units/reflex_base/components/test_dynamic.py: Comprehensive test coverage for the shims, including context isolation, deprecation warnings, and error handling
- news/6382.breaking.md and news/+bundled-libraries-shim.deprecation.md: Updated breaking change notes to document the deprecation path
Test Plan
Added unit tests covering:
- Shim returns active context's bundled_libraries
- Shim works via reflex namespace (reflex.components.dynamic)
- DEFAULT_BUNDLED_LIBRARIES shim returns correct default list
- Deprecation warnings are emitted with correct feature names
- Unknown attributes raise AttributeError with proper module name
All tests pass with adequate coverage.
Checklist
- Tests pass with adequate coverage
-
uv run ruff check .anduv run ruff format .clean -
uv run pyright reflex testspasses - Documentation updated (news files)
- Deprecation warnings added with proper version info