Skip to content

Add deprecation shims for bundled_libraries module globals - #6967

Merged
masenf merged 2 commits into
mainfrom
claude/reflex-enterprise-shim-mvevpt
Aug 28, 2026
Merged

Add deprecation shims for bundled_libraries module globals#6967
masenf merged 2 commits into
mainfrom
claude/reflex-enterprise-shim-mvevpt

Conversation

@masenf

@masenf masenf commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

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:

  1. Resolve against the active RegistrationContext when accessed
  2. Emit deprecation warnings (removal in 1.0) directing users to the new API
  3. Properly propagate AttributeError for unknown attributes

The shims are implemented in:

  • reflex_base.components.dynamic.__getattr__() — handles the actual resolution
  • reflex/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 to bundled_libraries and DEFAULT_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 . and uv run ruff format . clean
  • uv run pyright reflex tests passes
  • Documentation updated (news files)
  • Deprecation warnings added with proper version info

https://claude.ai/code/session_019RU2VRJPPA3MWrjCGL15sy

Review in cubic

#6382 moved the module-level `bundled_libraries` list out of
`reflex_base.components.dynamic` and onto `RegistrationContext`, which
breaks every published reflex-enterprise (0.8.0 through 0.9.4a4 all read
`dynamic.bundled_libraries` in `LiteralLambdaVar._validate_and_extend_return_expr`)
when paired with reflex-base 0.9.9.

Add a module-level `__getattr__` that resolves `bundled_libraries` (and
`DEFAULT_BUNDLED_LIBRARIES`) against the active `RegistrationContext` and
emits a deprecation warning pointing at the new API. Because it resolves
on each attribute access, callers see the live list for whatever context
is current rather than an import-time snapshot.

reflex-enterprise reaches the module through `reflex.components.dynamic`,
whose star re-export cannot see a module-level `__getattr__`, so that
shim module gets a `__getattr__` delegating any missed name to
`reflex_base.components.dynamic`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019RU2VRJPPA3MWrjCGL15sy
@masenf
masenf requested a review from a team as a code owner August 28, 2026 07:53
@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores deprecated read compatibility for bundled-library module globals by resolving them through the active registration context.

  • Adds compatibility accessors in both the base and re-exported dynamic-component modules.
  • Emits migration-oriented deprecation warnings while preserving unknown-attribute errors.
  • Adds tests for context isolation, namespace delegation, defaults, warnings, and error handling.
  • Updates release notes to document the compatibility period and removal target.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/components/dynamic.py Adds deprecated module-level attribute shims backed by RegistrationContext while preserving standard AttributeError behavior.
reflex/components/dynamic.py Delegates attributes omitted by the wildcard re-export to the base dynamic-components module.
tests/units/reflex_base/components/test_dynamic.py Covers active-context resolution, namespace delegation, default values, warning emission, and unknown attributes.
news/+bundled-libraries-shim.deprecation.md Documents the deprecated compatibility API and recommended replacements.
packages/reflex-base/news/6382.breaking.md Clarifies that legacy reads remain supported until version 1.0.

Reviews (2): Last reviewed commit: "Move bundled-libraries shim news fragmen..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Aug 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing claude/reflex-enterprise-shim-mvevpt (ef55b22) with main (f7c848f)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (45b8ed5) during the generation of this report, so f7c848f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

The fragment lands in the `reflex` changelog rather than reflex-base's,
so name the `reflex.components.dynamic` path users import from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019RU2VRJPPA3MWrjCGL15sy
masenf pushed a commit that referenced this pull request Aug 28, 2026
Maps in-flight PRs #6967/#6959 to findings, lists 11 fix-before-release
items (security, confirmed regressions, high-impact/simple), and the
post-release GitHub issue list for reflex and reflex-enterprise, with
suggested sequencing. No fixes applied.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EMjBXPozsNeQNSBZecNH8x
@masenf masenf added this to the v0.9.9 milestone Aug 28, 2026
@masenf
masenf merged commit 8f0e0a2 into main Aug 28, 2026
144 of 146 checks passed
@masenf
masenf deleted the claude/reflex-enterprise-shim-mvevpt branch August 28, 2026 18:37
masenf pushed a commit that referenced this pull request Aug 28, 2026
…-context-refactor-jv3pig

Picks up #6984, #6967 and #6985 — a client_error payload default and two
deprecation-shim restorations. Clean auto-merge; nothing touches client state,
memoization, or foreach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants