Skip to content

Formally deprecate register_widget() - #269

Draft
cpsievert wants to merge 1 commit into
mainfrom
deprecate-register-widget
Draft

cpsievert wants to merge 1 commit into
mainfrom
deprecate-register-widget

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Summary

Closes #127.

register_widget() doesn't follow the Shiny rendering pattern (calling a register method inside the server body doesn't read as "this will be rendered to the UI"), and its docstring has said "Deprecated. Use @render_widget instead." for a while — but no actual warning was emitted, so users had no signal at runtime.

Now it emits a deprecation warning (ShinyDeprecationWarning from shiny, falling back to DeprecationWarning on older shiny versions) pointing users at the @render_widget pattern:

# Deprecated
map_widget = register_widget("map", map)

# Recommended
@render_widget
def map():
    return map_val

Changes

  • shinywidgets/_shinywidgets.py: register_widget() now warns on every call.
  • tests/unit/test_widget_bootstrap.py: existing register_widget tests assert the warning; added a dedicated deprecation test.
  • CHANGELOG.md: new Deprecations section entry.

Verification

  • make test-unit — 151 passed, 1 xfailed
  • make pyright — 0 errors
  • make py-check-format — clean

It already didn't follow the Shiny rendering pattern and its docstring
said it was deprecated, but no warning was emitted. Now it warns with
shiny's ShinyDeprecationWarning (falling back to DeprecationWarning on
older shiny versions) and points users at the @render_widget pattern.

Closes #127
@cpsievert
cpsievert marked this pull request as draft October 20, 2026 22:26
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.

register_widget() should be deprecated

1 participant