[refactor] Log widget state duplication warning to console instead of UI#14141
[refactor] Log widget state duplication warning to console instead of UI#14141lukasmasuch merged 1 commit intodevelopfrom
Conversation
Change widget state duplication warning from st.warning() to _LOGGER.warning() to reduce UI clutter while still informing developers in the console. Added stack_info for easier debugging.
✅ PR preview is ready!
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Consolidated Code ReviewSummaryThis PR replaces the widget state duplication warning from a user-facing Reviewer ConsensusBoth reviewers (
Code Quality
Test CoverageTests are well-updated to reflect the new behavior:
Minor gap (noted by Backwards CompatibilityNo breaking API changes. The Minor Suggestions (Non-blocking)
Security & RiskNo security concerns. Risk is minimal — the logic flow is identical, only the output destination changes. VerdictAPPROVED: Both reviewers approved. The refactoring is clean, well-tested, follows existing codebase patterns, and includes a subtle bug fix in the test code. No blocking issues were identified. Consolidated review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR replaces the widget state duplication warning from a UI-visible Code QualityNo functional defects were identified in the changed logic. The refactor aligns with Minor style issue (non-blocking):
Test CoverageUnit coverage for the modified behavior is solid:
No e2e test was added for the UI behavior change (warning no longer rendered in-app). This is a small residual gap, but the direct call-site change from Backwards CompatibilityNo API or config-key breaking change was introduced. The main behavioral change is intentional: duplication warnings now go to logs instead of the app UI. Existing apps continue to run, and Security & RiskNo security concerns found. Risk is low and mostly limited to observability expectations (developers relying on UI warning visibility will now need to inspect logs). AccessibilityNo new frontend UI was introduced. Removing an in-app warning from this path reduces visual noise and does not introduce accessibility regressions. Recommendations
VerdictAPPROVED: The refactor is clean, low-risk, and adequately covered by updated unit tests, with only minor non-blocking follow-up suggestions. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR changes the widget state duplication warning from Code QualityThe code is clean and follows existing patterns well:
No issues found with code structure or maintainability. Test CoverageTests are well-updated to reflect the new behavior:
Coverage is adequate for this change. Backwards CompatibilityThis is a minor behavioral change for users:
This is intentionally a UX improvement (reducing visual noise). Users who relied on seeing this warning in the UI will need to check console logs instead. The No breaking API changes. No protobuf changes. No frontend changes needed. Security & RiskNo security concerns. The change is a straightforward swap from UI display to console logging. The warning message content is unchanged. The Risk of regression is minimal — the logic flow is identical, only the output destination changes. AccessibilityNo frontend changes are involved, so accessibility is not affected. Removing a UI warning element could arguably be a minor accessibility improvement since it reduces unexpected content changes in the app. RecommendationsNo blocking issues. One optional suggestion:
VerdictAPPROVED: Clean, well-tested refactoring that moves the widget state duplication warning from UI display to console logging, following existing patterns in the codebase and fixing a minor pre-existing test bug. This is an automated AI review by |
There was a problem hiding this comment.
Pull request overview
This PR refactors the widget state duplication warning from a UI-displayed warning (st.warning()) to a console-logged warning (_LOGGER.warning()), reducing visual clutter in apps while still alerting developers to potential configuration issues. The change adds stack_info=True for better debugging capabilities, helping developers trace where the warning originates.
Changes:
- Changed warning output method from UI display to console logging for widget state duplication
- Added stack trace information to the warning for improved debugging
- Updated all related tests to mock and verify the logger instead of the UI warning function
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/streamlit/elements/lib/policies.py | Changed st.warning() to _LOGGER.warning() with stack_info=True and updated the warning message format to use string formatting with positional arguments |
| lib/tests/streamlit/elements/element_policies_test.py | Updated all test mocks from streamlit.warning to streamlit.elements.lib.policies._LOGGER, removed unused import, fixed typo ("globale" -> "global"), and added assertions to verify logger call arguments including stack_info |
| lib/streamlit/config.py | Updated documentation to reflect that the warning is now logged to console rather than displayed in the UI |
Describe your changes
Changes widget state duplication warning from
st.warning()(UI display) to_LOGGER.warning()(console output), reducing visual noise while still informing developers.stack_info=Truefor better debugging (shows where warning originates)Testing Plan