Skip reflex_components_* frames in deprecation warning locations

Merged
MA
13d ago
+20-1

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Description

Found in the reflex 0.11.0a1 pre-release testing (FINDING-028).

A deprecation warning names the first stack frame outside the framework. _exclude_paths_from_frame_info in reflex_base/utils/log.py excluded reflex, reflex_base, click, socketio, granian, typing_extensions and the stdlib, but not the component packages split out of reflex. So rx.input(on_change=client_state.set_value) reported a file inside reflex_components_* (for example .../site-packages/reflex_components_core/el/elements/forms.py:857) instead of the app's line.

This PR adds the root of every importable reflex_components_* package to the exclude roots. The names come from pkgutil.iter_modules(), which lists the sys.path entries and costs about 10 ms. They are resolved through the same find_spec path as the stdlib roots, inside the existing @once function, so the work happens once per process.

Checked end to end: a script calling rx.input(on_change=cs.set_value) reports reflex-components-radix/src/reflex_components_radix/... on main and (user_app.py:5) with this change.

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

New test: tests/units/reflex_base/utils/test_log.py::test_component_packages_are_framework_code. It fails on main and passes with this change. tests/units/reflex_base/utils and tests/units/utils pass, and ruff, ruff format, pyright and pre-commit are clean on the changed files.


Generated by Claude Code