From 2faddb5cf661db8054e4e5dd0ab97fc34d271046 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Tue, 14 Oct 2025 09:56:26 -0700 Subject: [PATCH 1/6] Deprecate output_text_verbatim with warning Added a deprecation warning to the output_text_verbatim --- shiny/ui/_output.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shiny/ui/_output.py b/shiny/ui/_output.py index 5d98d7c429..4dedbd0e2d 100644 --- a/shiny/ui/_output.py +++ b/shiny/ui/_output.py @@ -10,10 +10,12 @@ "output_ui", ) +import warnings from typing import Optional from htmltools import Tag, TagAttrValue, TagFunction, css, div, tags +from .._deprecated import ShinyDeprecationWarning from .._docstring import add_example, no_example from ..module import resolve_id from ..types import MISSING, MISSING_TYPE @@ -346,6 +348,14 @@ def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: See :func:`~shiny.ui.output_text` """ + warnings.warn( + "`ui.output_text_verbatim()` is deprecated. " + "Please use `ui.output_text()` if you want to create an output container for some text, " + "or `ui.output_code()` if you want to create an output container for code (monospaced text).", + category=ShinyDeprecationWarning, + stacklevel=2, + ) + cls = "shiny-text-output" + (" noplaceholder" if not placeholder else "") return tags.pre(id=resolve_id(id), class_=cls) From 7dfc8667a77713177fae75542f126d74840e3508 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Tue, 14 Oct 2025 09:58:54 -0700 Subject: [PATCH 2/6] Document deprecation of ui.output_text_verbatim() `ui.output_text_verbatim()` is now deprecated in favor of `ui.output_text()` for text output and `ui.output_code()` for code output. This update adds a deprecation notice to the changelog. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25444d59d6..1961043dea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to Shiny for Python will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Deprecations + +* `ui.output_text_verbatim()` is deprecated. Please use `ui.output_text()` if you want to create an output container for some text, or `ui.output_code()` if you want to create an output container for code (monospaced text). (#2097) + ## [1.5.0] - 2025-09-11 ### New features From 73e11067becd1a7eabb6cc1db4dd35fe11bb2c18 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Tue, 14 Oct 2025 10:09:43 -0700 Subject: [PATCH 3/6] Replace output_text_verbatim with output_code in UI --- examples/brand/app.py | 2 +- shiny/api-examples/ClientData/app-core.py | 2 +- shiny/api-examples/Renderer/app-core.py | 8 ++++---- shiny/api-examples/accordion/app-core.py | 4 ++-- shiny/api-examples/accordion_panel/app-core.py | 2 +- shiny/api-examples/calc/app-core.py | 2 +- shiny/api-examples/input_numeric/app-core.py | 2 +- shiny/api-examples/input_password/app-core.py | 2 +- shiny/api-examples/input_text/app-core.py | 2 +- shiny/api-examples/input_text_area/app-core.py | 4 ++-- shiny/api-examples/output_text/app-core.py | 8 ++++---- shiny/api-examples/output_transformer/app-core.py | 6 +++--- shiny/api-examples/popover/app-core.py | 2 +- shiny/api-examples/sidebar/app-core-dynamic.py | 2 +- shiny/api-examples/sidebar/app-core.py | 8 ++++---- shiny/api-examples/template/app-core.py | 2 +- shiny/api-examples/theme/__purgecss.py | 2 +- shiny/api-examples/theme/app-core-local.py | 2 +- shiny/api-examples/theme/app-core-remote.py | 2 +- shiny/api-examples/theme/app-core-shinyswatch.py | 2 +- shiny/api-examples/theme/app-core.py | 2 +- shiny/api-examples/update_sidebar/app-core.py | 2 +- shiny/templates/app/01-basic-app/app-core.py | 2 +- tests/playwright/shiny/async/app.py | 2 +- .../bugs/0648-update-slider-datetime-value/app.py | 2 +- tests/playwright/shiny/bugs/0696-resolve-id/app.py | 8 ++++---- .../shiny/bugs/1345-render-data-frame-input/app.py | 4 ++-- .../bugs/1351-render-data-frame-selected/app.py | 2 +- .../shiny/components/busy_indicators/app.py | 2 +- .../components/data_frame/data_view_info/app.py | 10 +++++----- .../shiny/components/data_frame/df_methods/app.py | 10 +++++----- .../shiny/components/data_frame/html_columns/app.py | 6 ++---- .../shiny/deprecated/output_transformer/app.py | 8 ++++---- tests/playwright/shiny/implicit-register/app.py | 2 +- tests/playwright/shiny/inputs/input_file/app.py | 2 +- .../shiny/inputs/input_radio_checkbox_group/app.py | 8 ++++---- tests/playwright/shiny/inputs/input_slider/app.py | 2 +- .../shiny/inputs/input_text_update_on/app.py | 8 ++++---- .../shiny/server/output_transformer/app.py | 12 ++++++------ tests/playwright/shiny/server/reactive_event/app.py | 6 +++--- tests/playwright/shiny/session/flush/app.py | 10 +++++----- 41 files changed, 87 insertions(+), 89 deletions(-) diff --git a/examples/brand/app.py b/examples/brand/app.py index e952cb53d8..89f604f00e 100644 --- a/examples/brand/app.py +++ b/examples/brand/app.py @@ -52,7 +52,7 @@ ), ui.card( ui.card_header("Text Output"), - ui.output_text_verbatim("out_text1"), + ui.output_code("out_text1"), ), ), ), diff --git a/shiny/api-examples/ClientData/app-core.py b/shiny/api-examples/ClientData/app-core.py index 5faf4fea97..102e008656 100644 --- a/shiny/api-examples/ClientData/app-core.py +++ b/shiny/api-examples/ClientData/app-core.py @@ -19,7 +19,7 @@ to reactively read the client data values from the browser. """ ), - ui.output_text_verbatim("clientdatatext"), + ui.output_code("clientdatatext"), ui.output_plot("myplot"), ) diff --git a/shiny/api-examples/Renderer/app-core.py b/shiny/api-examples/Renderer/app-core.py index 3931c17e8b..aa570408ff 100644 --- a/shiny/api-examples/Renderer/app-core.py +++ b/shiny/api-examples/Renderer/app-core.py @@ -9,13 +9,13 @@ ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "@render_upper: ", - ui.output_text_verbatim("upper", placeholder=True), + ui.output_code("upper", placeholder=True), "@render_upper(): ", - ui.output_text_verbatim("upper_with_paren", placeholder=True), + ui.output_code("upper_with_paren", placeholder=True), "@render_capitalize: ", - ui.output_text_verbatim("cap_upper", placeholder=True), + ui.output_code("cap_upper", placeholder=True), "@render_capitalize(to='lower'): ", - ui.output_text_verbatim("cap_lower", placeholder=True), + ui.output_code("cap_lower", placeholder=True), ) diff --git a/shiny/api-examples/accordion/app-core.py b/shiny/api-examples/accordion/app-core.py index 4c91ec8d5c..ebde52f35e 100644 --- a/shiny/api-examples/accordion/app-core.py +++ b/shiny/api-examples/accordion/app-core.py @@ -25,11 +25,11 @@ def make_items(): ui.markdown("#### Accordion: (`multiple=False`)"), # Provide an id to create a shiny input binding ui.accordion(*make_items(), id="acc_single", multiple=False), - ui.output_text_verbatim("acc_single_val", placeholder=True), + ui.output_code("acc_single_val", placeholder=True), ui.tags.br(), ui.markdown("#### Accordion: (`multiple=True`)"), ui.accordion(*make_items(), id="acc_multiple"), - ui.output_text_verbatim("acc_multiple_val", placeholder=True), + ui.output_code("acc_multiple_val", placeholder=True), ) diff --git a/shiny/api-examples/accordion_panel/app-core.py b/shiny/api-examples/accordion_panel/app-core.py index c53697eb01..6c266e0e19 100644 --- a/shiny/api-examples/accordion_panel/app-core.py +++ b/shiny/api-examples/accordion_panel/app-core.py @@ -9,7 +9,7 @@ # Provide an id to create a shiny input binding ui.accordion(*items, id="acc"), ui.h4("Accordion:"), - ui.output_text_verbatim("acc_val", placeholder=True), + ui.output_code("acc_val", placeholder=True), ) diff --git a/shiny/api-examples/calc/app-core.py b/shiny/api-examples/calc/app-core.py index fe2620253d..bf12585ef5 100644 --- a/shiny/api-examples/calc/app-core.py +++ b/shiny/api-examples/calc/app-core.py @@ -9,7 +9,7 @@ ui.input_action_button("first", "Invalidate first (slow) computation"), ui.input_action_button("second", "Invalidate second (fast) computation"), ), - ui.output_text_verbatim("result"), + ui.output_code("result"), ) ) diff --git a/shiny/api-examples/input_numeric/app-core.py b/shiny/api-examples/input_numeric/app-core.py index 3c6f2b0dc0..312f9b5b01 100644 --- a/shiny/api-examples/input_numeric/app-core.py +++ b/shiny/api-examples/input_numeric/app-core.py @@ -2,7 +2,7 @@ app_ui = ui.page_fluid( ui.input_numeric("obs", "Observations:", 10, min=1, max=100), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) diff --git a/shiny/api-examples/input_password/app-core.py b/shiny/api-examples/input_password/app-core.py index 4d56c7024f..bcddcd764b 100644 --- a/shiny/api-examples/input_password/app-core.py +++ b/shiny/api-examples/input_password/app-core.py @@ -3,7 +3,7 @@ app_ui = ui.page_fluid( ui.input_password("password", "Password:"), ui.input_action_button("go", "Go"), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) diff --git a/shiny/api-examples/input_text/app-core.py b/shiny/api-examples/input_text/app-core.py index bf6ddd8596..016338f109 100644 --- a/shiny/api-examples/input_text/app-core.py +++ b/shiny/api-examples/input_text/app-core.py @@ -2,7 +2,7 @@ app_ui = ui.page_fluid( ui.input_text("caption", "Caption:", "Data summary"), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) diff --git a/shiny/api-examples/input_text_area/app-core.py b/shiny/api-examples/input_text_area/app-core.py index 3c708bc4e0..8c6b458d42 100644 --- a/shiny/api-examples/input_text_area/app-core.py +++ b/shiny/api-examples/input_text_area/app-core.py @@ -6,14 +6,14 @@ "Caption:", "Data summary\nwith\nmultiple\nlines", ), - ui.output_text_verbatim("value_regular", placeholder=True), + ui.output_code("value_regular", placeholder=True), ui.input_text_area( "caption_autoresize", ui.markdown("Caption (w/ `autoresize=True`):"), "Data summary\nwith\nmultiple\nlines", autoresize=True, ), - ui.output_text_verbatim("value_autoresize", placeholder=True), + ui.output_code("value_autoresize", placeholder=True), ) diff --git a/shiny/api-examples/output_text/app-core.py b/shiny/api-examples/output_text/app-core.py index cf0d8e3d96..d4800c99e6 100644 --- a/shiny/api-examples/output_text/app-core.py +++ b/shiny/api-examples/output_text/app-core.py @@ -6,16 +6,16 @@ ui.column(6, ui.code("ui.output_text()"), ui.output_text("text")), ui.column( 6, - ui.code("ui.output_text_verbatim(placeholder=True)"), - ui.output_text_verbatim("verb", placeholder=True), + ui.code("ui.output_code(placeholder=True)"), + ui.output_code("verb", placeholder=True), ), ), ui.row( ui.column(6), ui.column( 6, - ui.code("ui.output_text_verbatim(placeholder=False)"), - ui.output_text_verbatim("verb_no_placeholder", placeholder=False), + ui.code("ui.output_code(placeholder=False)"), + ui.output_code("verb_no_placeholder", placeholder=False), ), ), ) diff --git a/shiny/api-examples/output_transformer/app-core.py b/shiny/api-examples/output_transformer/app-core.py index e1c6a6a884..4dd98e0dae 100644 --- a/shiny/api-examples/output_transformer/app-core.py +++ b/shiny/api-examples/output_transformer/app-core.py @@ -109,11 +109,11 @@ def render_capitalize( ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "Renderer called with out parentheses:", - ui.output_text_verbatim("no_parens"), + ui.output_code("no_parens"), "To upper:", - ui.output_text_verbatim("to_upper"), + ui.output_code("to_upper"), "To lower:", - ui.output_text_verbatim("to_lower"), + ui.output_code("to_lower"), ) diff --git a/shiny/api-examples/popover/app-core.py b/shiny/api-examples/popover/app-core.py index 474821028a..e8d76682eb 100644 --- a/shiny/api-examples/popover/app-core.py +++ b/shiny/api-examples/popover/app-core.py @@ -25,7 +25,7 @@ id="card_popover", ), ), - ui.output_text_verbatim("plot_txt", placeholder=True), + ui.output_code("plot_txt", placeholder=True), ), ) diff --git a/shiny/api-examples/sidebar/app-core-dynamic.py b/shiny/api-examples/sidebar/app-core-dynamic.py index ec55e44968..50abf99483 100644 --- a/shiny/api-examples/sidebar/app-core-dynamic.py +++ b/shiny/api-examples/sidebar/app-core-dynamic.py @@ -58,7 +58,7 @@ def sidebar_dynamic_container(): position=input.position(), ), ui.h2("Dynamic sidebar"), - ui.output_text_verbatim("state_dynamic"), + ui.output_code("state_dynamic"), ) @render.text diff --git a/shiny/api-examples/sidebar/app-core.py b/shiny/api-examples/sidebar/app-core.py index 48e4c53d72..4971707008 100644 --- a/shiny/api-examples/sidebar/app-core.py +++ b/shiny/api-examples/sidebar/app-core.py @@ -4,25 +4,25 @@ ui.card( ui.layout_sidebar( ui.sidebar("Left sidebar content", id="sidebar_left"), - ui.output_text_verbatim("state_left"), + ui.output_code("state_left"), ) ), ui.card( ui.layout_sidebar( ui.sidebar("Right sidebar content", id="sidebar_right", position="right"), - ui.output_text_verbatim("state_right"), + ui.output_code("state_right"), ), ), ui.card( ui.layout_sidebar( ui.sidebar("Closed sidebar content", id="sidebar_closed", open="closed"), - ui.output_text_verbatim("state_closed"), + ui.output_code("state_closed"), ) ), ui.card( ui.layout_sidebar( ui.sidebar("Always sidebar content", id="sidebar_always", open="always"), - ui.output_text_verbatim("state_always"), + ui.output_code("state_always"), ) ), ) diff --git a/shiny/api-examples/template/app-core.py b/shiny/api-examples/template/app-core.py index 7dacdbec23..0d43aafd2d 100644 --- a/shiny/api-examples/template/app-core.py +++ b/shiny/api-examples/template/app-core.py @@ -3,7 +3,7 @@ app_ui = ui.page_fluid( ui.panel_title("Hello Shiny!"), ui.input_slider("n", "N", 0, 100, 20), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ) diff --git a/shiny/api-examples/theme/__purgecss.py b/shiny/api-examples/theme/__purgecss.py index ebd1f8fba6..4d5a4f1364 100644 --- a/shiny/api-examples/theme/__purgecss.py +++ b/shiny/api-examples/theme/__purgecss.py @@ -26,7 +26,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=my_theme, diff --git a/shiny/api-examples/theme/app-core-local.py b/shiny/api-examples/theme/app-core-local.py index 133b3fcb62..78ecdac931 100644 --- a/shiny/api-examples/theme/app-core-local.py +++ b/shiny/api-examples/theme/app-core-local.py @@ -10,7 +10,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=Path(__file__).parent / "css" / "shiny-theme-demo.css", diff --git a/shiny/api-examples/theme/app-core-remote.py b/shiny/api-examples/theme/app-core-remote.py index b55ad59920..e7bb73df84 100644 --- a/shiny/api-examples/theme/app-core-remote.py +++ b/shiny/api-examples/theme/app-core-remote.py @@ -8,7 +8,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme="https://cdn.jsdelivr.net/npm/bootswatch@5.3.3/dist/sketchy/bootstrap.min.css", diff --git a/shiny/api-examples/theme/app-core-shinyswatch.py b/shiny/api-examples/theme/app-core-shinyswatch.py index 0bb94a5663..38b7fb542c 100644 --- a/shiny/api-examples/theme/app-core-shinyswatch.py +++ b/shiny/api-examples/theme/app-core-shinyswatch.py @@ -9,7 +9,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=shinyswatch.theme.slate(), diff --git a/shiny/api-examples/theme/app-core.py b/shiny/api-examples/theme/app-core.py index a4ac8241bc..961e5bca5d 100644 --- a/shiny/api-examples/theme/app-core.py +++ b/shiny/api-examples/theme/app-core.py @@ -10,7 +10,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=my_theme, diff --git a/shiny/api-examples/update_sidebar/app-core.py b/shiny/api-examples/update_sidebar/app-core.py index 9dc0a155d7..74084c4462 100644 --- a/shiny/api-examples/update_sidebar/app-core.py +++ b/shiny/api-examples/update_sidebar/app-core.py @@ -6,7 +6,7 @@ ui.input_action_button("close_sidebar", label="Close sidebar", class_="me-3"), ui.br(), ui.br(), - ui.output_text_verbatim("state"), + ui.output_code("state"), fillable=False, ) diff --git a/shiny/templates/app/01-basic-app/app-core.py b/shiny/templates/app/01-basic-app/app-core.py index 7dacdbec23..0d43aafd2d 100644 --- a/shiny/templates/app/01-basic-app/app-core.py +++ b/shiny/templates/app/01-basic-app/app-core.py @@ -3,7 +3,7 @@ app_ui = ui.page_fluid( ui.panel_title("Hello Shiny!"), ui.input_slider("n", "N", 0, 100, 20), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ) diff --git a/tests/playwright/shiny/async/app.py b/tests/playwright/shiny/async/app.py index cafa7dbc88..60362afb7e 100644 --- a/tests/playwright/shiny/async/app.py +++ b/tests/playwright/shiny/async/app.py @@ -18,7 +18,7 @@ def calc(value: str) -> str: "value", "Value to sha256sum", value="The quick brown fox", rows=5, width="100%" ), ui.p(ui.input_action_button("go", "Calculate"), class_="mb-3"), - ui.output_text_verbatim("hash_output"), + ui.output_code("hash_output"), ) diff --git a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py index b9025647a7..08b2fd4136 100644 --- a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py +++ b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py @@ -28,7 +28,7 @@ def slider_with_reset_ui( timezone="UTC", time_format="%H:%M:%S", ), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.div(ui.input_action_button("reset", label)), ) diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/app.py b/tests/playwright/shiny/bugs/0696-resolve-id/app.py index 7a2bcc5c75..be56e6de29 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/app.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/app.py @@ -99,11 +99,11 @@ def ui_navs(label: str) -> list[ui._navs.NavPanel]: ), ui.layout_column_wrap( *[ - ui.output_text_verbatim(f"status_x_{x_input_key}", placeholder=True) + ui.output_code(f"status_x_{x_input_key}", placeholder=True) for x_input_key in x_input_keys ], *[ - ui.output_text_verbatim(f"status_{input_key}", placeholder=True) + ui.output_code(f"status_{input_key}", placeholder=True) for input_key in input_keys ], width=1 / 2, @@ -200,7 +200,7 @@ def ui_navs(label: str) -> list[ui._navs.NavPanel]: "Image (Changes w/ `input.radio_buttons()`)", ui.output_image("out_image", height="180px"), ), - ("Text Verbatim", ui.output_text_verbatim("out_text_verbatim")), + ("Text Verbatim", ui.output_code("out_text_verbatim")), ("Text", ui.output_text("out_text")), ("UI", ui.output_ui("out_ui")), ) @@ -371,7 +371,7 @@ def preprocess_file(x: Any) -> str: width=1 / 3, ), # ui.h3("Inputs that are not in a module:"), - # ui.output_text_verbatim("not_modules", placeholder=True), + # ui.output_code("not_modules", placeholder=True), ) diff --git a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py index 525dd197a0..711f3f8cd8 100644 --- a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py +++ b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py @@ -4,8 +4,8 @@ app_ui = ui.page_fluid( ui.output_data_frame("df1"), - ui.output_text_verbatim("selected_rows", placeholder=True), - ui.output_text_verbatim("cell_selection", placeholder=True), + ui.output_code("selected_rows", placeholder=True), + ui.output_code("cell_selection", placeholder=True), ) diff --git a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py index d81bc75d5d..ffba1d741e 100644 --- a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py +++ b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py @@ -14,7 +14,7 @@ ), ui.input_action_button("add_row", "Add row"), ui.input_action_button("clear_table", "Clear table"), - ui.output_text_verbatim("number_of_selected_rows"), + ui.output_code("number_of_selected_rows"), ui.output_data_frame("df1"), ) diff --git a/tests/playwright/shiny/components/busy_indicators/app.py b/tests/playwright/shiny/components/busy_indicators/app.py index 5c02e4bdf6..287d790d69 100644 --- a/tests/playwright/shiny/components/busy_indicators/app.py +++ b/tests/playwright/shiny/components/busy_indicators/app.py @@ -45,7 +45,7 @@ def plot(): inline=True, ), ui.input_task_button("rerender", "Re-render"), - ui.output_text_verbatim("counter", placeholder=True), + ui.output_code("counter", placeholder=True), ui.layout_columns( card_ui("ring", "ring", "red", "10px"), card_ui("bars", "bars", "green", "20px"), diff --git a/tests/playwright/shiny/components/data_frame/data_view_info/app.py b/tests/playwright/shiny/components/data_frame/data_view_info/app.py index 0d1a08d3c0..c0f3e77d64 100644 --- a/tests/playwright/shiny/components/data_frame/data_view_info/app.py +++ b/tests/playwright/shiny/components/data_frame/data_view_info/app.py @@ -21,11 +21,11 @@ def mod_ui(): ui.card( ui.layout_column_wrap( ui.TagList( - ui.div("Sort: ", ui.output_text_verbatim("sort")), - ui.div("Filter: ", ui.output_text_verbatim("filter")), - ui.div("Rows: ", ui.output_text_verbatim("rows")), - ui.div("Selected Rows: ", ui.output_text_verbatim("selected_rows")), - ui.div("Type: ", ui.output_text_verbatim("df_type")), + ui.div("Sort: ", ui.output_code("sort")), + ui.div("Filter: ", ui.output_code("filter")), + ui.div("Rows: ", ui.output_code("rows")), + ui.div("Selected Rows: ", ui.output_code("selected_rows")), + ui.div("Type: ", ui.output_code("df_type")), ), ui.output_data_frame("penguins_df"), width=1 / 2, diff --git a/tests/playwright/shiny/components/data_frame/df_methods/app.py b/tests/playwright/shiny/components/data_frame/df_methods/app.py index fb55d944f1..d87195f871 100644 --- a/tests/playwright/shiny/components/data_frame/df_methods/app.py +++ b/tests/playwright/shiny/components/data_frame/df_methods/app.py @@ -29,15 +29,15 @@ def mod_ui(): ui.br(), ui.output_data_frame("iris_df"), ui.h2("Data view indices"), - ui.output_text_verbatim("data_view_rows"), + ui.output_code("data_view_rows"), ui.h2("Indices when view_selected=True"), - ui.output_text_verbatim("data_view_selected_true"), + ui.output_code("data_view_selected_true"), ui.h2("Indices when view_selected=False"), - ui.output_text_verbatim("data_view_selected_false"), + ui.output_code("data_view_selected_false"), ui.h2("Show selected cell"), - ui.output_text_verbatim("cell_selection"), + ui.output_code("cell_selection"), ui.h2("Type:"), - ui.output_text_verbatim("df_type"), + ui.output_code("df_type"), ) diff --git a/tests/playwright/shiny/components/data_frame/html_columns/app.py b/tests/playwright/shiny/components/data_frame/html_columns/app.py index d6764e31d1..1e38475c7b 100644 --- a/tests/playwright/shiny/components/data_frame/html_columns/app.py +++ b/tests/playwright/shiny/components/data_frame/html_columns/app.py @@ -67,7 +67,7 @@ def random_generator(): ) pd_penguins.iloc[1, 5] = ui.p( # pyright: ignore[reportArgumentType] ui.input_action_button("pandas_test_cell_button", "Test button"), - ui.output_text_verbatim("pandas_test_cell_text", placeholder=True), + ui.output_code("pandas_test_cell_text", placeholder=True), ) @@ -116,9 +116,7 @@ def random_generator(): ui.input_action_button( "polars_test_cell_button", "Test button" ), - ui.output_text_verbatim( - "polars_test_cell_text", placeholder=True - ), + ui.output_code("polars_test_cell_text", placeholder=True), ) if i == 1 else ui.div(val) diff --git a/tests/playwright/shiny/deprecated/output_transformer/app.py b/tests/playwright/shiny/deprecated/output_transformer/app.py index 3ec9dfe38a..21db13d4c0 100644 --- a/tests/playwright/shiny/deprecated/output_transformer/app.py +++ b/tests/playwright/shiny/deprecated/output_transformer/app.py @@ -114,12 +114,12 @@ def render_capitalize( ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "Renderer called with out parentheses:", - ui.output_text_verbatim("no_output", placeholder=True), - ui.output_text_verbatim("no_parens", placeholder=True), + ui.output_code("no_output", placeholder=True), + ui.output_code("no_parens", placeholder=True), "To upper:", - ui.output_text_verbatim("to_upper", placeholder=True), + ui.output_code("to_upper", placeholder=True), "To lower:", - ui.output_text_verbatim("to_lower", placeholder=True), + ui.output_code("to_lower", placeholder=True), ) diff --git a/tests/playwright/shiny/implicit-register/app.py b/tests/playwright/shiny/implicit-register/app.py index eb88220a1d..8652f3c803 100644 --- a/tests/playwright/shiny/implicit-register/app.py +++ b/tests/playwright/shiny/implicit-register/app.py @@ -9,7 +9,7 @@ app_ui = ui.page_fluid( [ - ui.p(ui.div(desc), ui.output_text_verbatim(id, placeholder=True)) + ui.p(ui.div(desc), ui.output_code(id, placeholder=True)) for id, desc in scenarios.items() ] ) diff --git a/tests/playwright/shiny/inputs/input_file/app.py b/tests/playwright/shiny/inputs/input_file/app.py index 369d7f90ab..3690070182 100644 --- a/tests/playwright/shiny/inputs/input_file/app.py +++ b/tests/playwright/shiny/inputs/input_file/app.py @@ -15,7 +15,7 @@ ), ui.output_table("summary"), ui.input_file("file2", "Multiple files", multiple=True), - ui.output_text_verbatim("file2_info", placeholder=True), + ui.output_code("file2_info", placeholder=True), ) diff --git a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py index 898124cf1e..437fb8add7 100644 --- a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py +++ b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py @@ -15,7 +15,7 @@ "c": HTML("C"), }, ), - ui.output_text_verbatim("radio1_out", placeholder=True), + ui.output_code("radio1_out", placeholder=True), ), ui.column( 6, @@ -29,7 +29,7 @@ }, inline=True, ), - ui.output_text_verbatim("radio2_out", placeholder=True), + ui.output_code("radio2_out", placeholder=True), ), ), ui.row( @@ -44,7 +44,7 @@ "blue": ui.span("BLUE", style="color: #0000AA;"), }, ), - ui.output_text_verbatim("check1_out", placeholder=True), + ui.output_code("check1_out", placeholder=True), ), ui.column( 6, @@ -58,7 +58,7 @@ }, inline=True, ), - ui.output_text_verbatim("check2_out", placeholder=True), + ui.output_code("check2_out", placeholder=True), ), ), ) diff --git a/tests/playwright/shiny/inputs/input_slider/app.py b/tests/playwright/shiny/inputs/input_slider/app.py index f423c7fa86..30eadd0454 100644 --- a/tests/playwright/shiny/inputs/input_slider/app.py +++ b/tests/playwright/shiny/inputs/input_slider/app.py @@ -25,7 +25,7 @@ def slider_row( ), ui.column( 6, - ui.output_text_verbatim(f"txt{id_num}", placeholder=True), + ui.output_code(f"txt{id_num}", placeholder=True), ), ) diff --git a/tests/playwright/shiny/inputs/input_text_update_on/app.py b/tests/playwright/shiny/inputs/input_text_update_on/app.py index 51d74be5f6..57da89fdfd 100644 --- a/tests/playwright/shiny/inputs/input_text_update_on/app.py +++ b/tests/playwright/shiny/inputs/input_text_update_on/app.py @@ -73,13 +73,13 @@ def text_input_ui(update_on: Literal["change", "blur"] = "change"): ui.h2(f'updateOn="{update_on}"'), ui.layout_columns( ui.input_text("txt", "Text", value="Hello", update_on=update_on), - ui.div("Text", ui.output_text_verbatim("value_txt")), + ui.div("Text", ui.output_code("value_txt")), ui.input_text_area("txtarea", "Text Area", update_on=update_on), - ui.div("Text Area", ui.output_text_verbatim("value_txtarea")), + ui.div("Text Area", ui.output_code("value_txtarea")), ui.input_numeric("num", "Numeric", value=1, update_on=update_on), - ui.div("Numeric", ui.output_text_verbatim("value_num")), + ui.div("Numeric", ui.output_code("value_num")), ui.input_password("pwd", "Password", update_on=update_on), - ui.div("Password", ui.output_text_verbatim("value_pwd")), + ui.div("Password", ui.output_code("value_pwd")), col_widths=6, ), ui.input_action_button("update_text", "Update Text"), diff --git a/tests/playwright/shiny/server/output_transformer/app.py b/tests/playwright/shiny/server/output_transformer/app.py index 37d1063dc4..8d92ba0d98 100644 --- a/tests/playwright/shiny/server/output_transformer/app.py +++ b/tests/playwright/shiny/server/output_transformer/app.py @@ -58,17 +58,17 @@ def render_test_text( app_ui = ui.page_fluid( ui.code("t1:"), - ui.output_text_verbatim("t1"), + ui.output_code("t1"), ui.code("t2:"), - ui.output_text_verbatim("t2"), + ui.output_code("t2"), ui.code("t3:"), - ui.output_text_verbatim("t3"), + ui.output_code("t3"), ui.code("t4:"), - ui.output_text_verbatim("t4"), + ui.output_code("t4"), ui.code("t5:"), - ui.output_text_verbatim("t5"), + ui.output_code("t5"), ui.code("t6:"), - ui.output_text_verbatim("t6"), + ui.output_code("t6"), ) diff --git a/tests/playwright/shiny/server/reactive_event/app.py b/tests/playwright/shiny/server/reactive_event/app.py index 8fc83359f4..c95a0e469c 100644 --- a/tests/playwright/shiny/server/reactive_event/app.py +++ b/tests/playwright/shiny/server/reactive_event/app.py @@ -7,13 +7,13 @@ ui.input_action_button("btn_count", "Immediate Count"), ui.tags.br(), ui.tags.label("Rendered on click:"), - ui.output_text_verbatim("txt_immediate", placeholder=True), + ui.output_code("txt_immediate", placeholder=True), ui.input_action_button("btn_trigger", "Update Count"), ui.tags.br(), ui.tags.label("Reactive event on renderer:"), - ui.output_text_verbatim("txt_render_delayed", placeholder=True), + ui.output_code("txt_render_delayed", placeholder=True), ui.tags.label("Reactive event on reactive calc:"), - ui.output_text_verbatim("txt_reactive_delayed", placeholder=True), + ui.output_code("txt_reactive_delayed", placeholder=True), ) diff --git a/tests/playwright/shiny/session/flush/app.py b/tests/playwright/shiny/session/flush/app.py index 39c0468870..7f08741c77 100644 --- a/tests/playwright/shiny/session/flush/app.py +++ b/tests/playwright/shiny/session/flush/app.py @@ -33,15 +33,15 @@ ui.input_action_button("btn", "Click me!"), ui.tags.br(), ui.tags.span("Counter: "), - ui.output_text_verbatim("btn_txt", placeholder=True), + ui.output_code("btn_txt", placeholder=True), ui.tags.span("All events: "), - ui.output_text_verbatim("all_txt", placeholder=True), + ui.output_code("all_txt", placeholder=True), ui.tags.span("Flush events: "), - ui.output_text_verbatim("flush_txt", placeholder=True), + ui.output_code("flush_txt", placeholder=True), ui.tags.span("Flushed events: "), - ui.output_text_verbatim("flushed_txt", placeholder=True), + ui.output_code("flushed_txt", placeholder=True), ui.tags.span("Session end events (refresh App to add events): "), - ui.output_text_verbatim("session_end_txt", placeholder=True), + ui.output_code("session_end_txt", placeholder=True), ui.tags.script( """ $(document).on('shiny:connected', function(event) { From db81153744a300fabaf714d1ffd208dfc0e629c2 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Tue, 14 Oct 2025 14:27:56 -0700 Subject: [PATCH 4/6] Replace output_text_verbatim with output_code in renderers --- shiny/api-examples/Renderer/renderers.py | 6 +++--- tests/playwright/examples/example_apps.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shiny/api-examples/Renderer/renderers.py b/shiny/api-examples/Renderer/renderers.py index a46dbc7be2..7e1d27df91 100644 --- a/shiny/api-examples/Renderer/renderers.py +++ b/shiny/api-examples/Renderer/renderers.py @@ -3,7 +3,7 @@ from typing import Literal, Optional from shiny.render.renderer import Renderer, ValueFn -from shiny.ui import output_text_verbatim +from shiny.ui import output_code class render_capitalize(Renderer[str]): @@ -28,7 +28,7 @@ def auto_output_ui(self): """ Express UI for the renderer """ - return output_text_verbatim(self.output_id, placeholder=True) + return output_code(self.output_id, placeholder=True) def __init__( self, @@ -94,7 +94,7 @@ def auto_output_ui(self): """ Express UI for the renderer """ - return output_text_verbatim(self.output_id, placeholder=True) + return output_code(self.output_id, placeholder=True) async def transform(self, value: str) -> str: """ diff --git a/tests/playwright/examples/example_apps.py b/tests/playwright/examples/example_apps.py index ce31d30022..112d4e869e 100644 --- a/tests/playwright/examples/example_apps.py +++ b/tests/playwright/examples/example_apps.py @@ -91,6 +91,8 @@ def get_apps(path: str) -> typing.List[str]: "FutureWarning: use_inf_as_na option is deprecated", "pd.option_context('mode.use_inf_as_na", # continutation of line above, "RuntimeWarning: invalid value encountered in dot", # some groups didn't have enough data points to create a meaningful line + # output_text_verbatim deprecation: https://github.com/posit-dev/py-shiny/pull/2097 + "ShinyDeprecationWarning: `ui.output_text_verbatim()` is deprecated.", ] app_allow_js_errors: typing.Dict[str, typing.List[str]] = { "examples/brownian": ["Failed to acquire camera feed:"], From 80ff1cebaf1eb74818eb5374ba405095122d9c1c Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 16 Oct 2025 21:42:45 -0700 Subject: [PATCH 5/6] Switch output from render.text to render.code Replaces @render.text with @render.code in multiple example, test, and template apps to standardize output for monospaced/code-style text. Updates documentation and deprecation warnings to reflect the change, and removes related test error allowances for deprecated output_text_verbatim usage. --- examples/brand/app.py | 2 +- shiny/api-examples/accordion/app-core.py | 4 ++-- shiny/api-examples/accordion_panel/app-core.py | 2 +- shiny/api-examples/calc/app-core.py | 2 +- shiny/api-examples/input_numeric/app-core.py | 2 +- shiny/api-examples/input_password/app-core.py | 2 +- shiny/api-examples/input_text/app-core.py | 2 +- shiny/api-examples/input_text_area/app-core.py | 4 ++-- shiny/api-examples/output_text/app-core.py | 4 ++-- shiny/api-examples/popover/app-core.py | 2 +- shiny/api-examples/sidebar/app-core-dynamic.py | 2 +- shiny/api-examples/sidebar/app-core.py | 8 ++++---- shiny/api-examples/template/app-core.py | 2 +- shiny/api-examples/theme/app-core-local.py | 2 +- shiny/api-examples/theme/app-core-remote.py | 2 +- .../api-examples/theme/app-core-shinyswatch.py | 2 +- shiny/api-examples/theme/app-core.py | 2 +- shiny/api-examples/update_sidebar/app-core.py | 2 +- shiny/templates/app/01-basic-app/app-core.py | 2 +- shiny/ui/_output.py | 18 ++++++++---------- tests/playwright/examples/example_apps.py | 2 -- .../0648-update-slider-datetime-value/app.py | 2 +- .../shiny/bugs/0696-resolve-id/app.py | 6 +++--- .../bugs/1345-render-data-frame-input/app.py | 4 ++-- .../1351-render-data-frame-selected/app.py | 2 +- .../shiny/components/busy_indicators/app.py | 2 +- .../components/data_frame/html_columns/app.py | 4 ++-- .../playwright/shiny/implicit-register/app.py | 4 ++-- .../playwright/shiny/inputs/input_file/app.py | 2 +- .../inputs/input_radio_checkbox_group/app.py | 8 ++++---- .../shiny/inputs/input_slider/app.py | 2 +- .../shiny/inputs/input_text_update_on/app.py | 8 ++++---- .../shiny/server/reactive_event/app.py | 6 +++--- tests/playwright/shiny/session/flush/app.py | 10 +++++----- 34 files changed, 63 insertions(+), 67 deletions(-) diff --git a/examples/brand/app.py b/examples/brand/app.py index 89f604f00e..e3143e62d1 100644 --- a/examples/brand/app.py +++ b/examples/brand/app.py @@ -279,7 +279,7 @@ def plot1(): spine.set_alpha(0.25) return fig - @render.text + @render.code def out_text1(): return "\n".join( ["def example_function():", ' return "Function output text"'] diff --git a/shiny/api-examples/accordion/app-core.py b/shiny/api-examples/accordion/app-core.py index ebde52f35e..f473186ce2 100644 --- a/shiny/api-examples/accordion/app-core.py +++ b/shiny/api-examples/accordion/app-core.py @@ -34,11 +34,11 @@ def make_items(): def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def acc_single_val(): return "input.acc_single(): " + str(input.acc_single()) - @render.text + @render.code def acc_multiple_val(): return "input.acc_multiple(): " + str(input.acc_multiple()) diff --git a/shiny/api-examples/accordion_panel/app-core.py b/shiny/api-examples/accordion_panel/app-core.py index 6c266e0e19..946eb1c813 100644 --- a/shiny/api-examples/accordion_panel/app-core.py +++ b/shiny/api-examples/accordion_panel/app-core.py @@ -18,7 +18,7 @@ def server(input: Inputs, output: Outputs, session: Session): def _(): print(input.acc()) - @render.text + @render.code def acc_val(): return "input.acc(): " + str(input.acc()) diff --git a/shiny/api-examples/calc/app-core.py b/shiny/api-examples/calc/app-core.py index bf12585ef5..7f998853fd 100644 --- a/shiny/api-examples/calc/app-core.py +++ b/shiny/api-examples/calc/app-core.py @@ -30,7 +30,7 @@ def second(): input.second() return random.randint(1, 1000) - @render.text + @render.code def result(): return first() + second() diff --git a/shiny/api-examples/input_numeric/app-core.py b/shiny/api-examples/input_numeric/app-core.py index 312f9b5b01..ff2bde8b25 100644 --- a/shiny/api-examples/input_numeric/app-core.py +++ b/shiny/api-examples/input_numeric/app-core.py @@ -7,7 +7,7 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value(): return input.obs() diff --git a/shiny/api-examples/input_password/app-core.py b/shiny/api-examples/input_password/app-core.py index bcddcd764b..08503739de 100644 --- a/shiny/api-examples/input_password/app-core.py +++ b/shiny/api-examples/input_password/app-core.py @@ -8,7 +8,7 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code @reactive.event(input.go) def value(): return input.password() diff --git a/shiny/api-examples/input_text/app-core.py b/shiny/api-examples/input_text/app-core.py index 016338f109..34872d8d16 100644 --- a/shiny/api-examples/input_text/app-core.py +++ b/shiny/api-examples/input_text/app-core.py @@ -7,7 +7,7 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value(): return input.caption() diff --git a/shiny/api-examples/input_text_area/app-core.py b/shiny/api-examples/input_text_area/app-core.py index 8c6b458d42..3af5ec423f 100644 --- a/shiny/api-examples/input_text_area/app-core.py +++ b/shiny/api-examples/input_text_area/app-core.py @@ -18,11 +18,11 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value_regular(): return input.caption_regular() - @render.text + @render.code def value_autoresize(): return input.caption_autoresize() diff --git a/shiny/api-examples/output_text/app-core.py b/shiny/api-examples/output_text/app-core.py index d4800c99e6..f19cef8119 100644 --- a/shiny/api-examples/output_text/app-core.py +++ b/shiny/api-examples/output_text/app-core.py @@ -26,11 +26,11 @@ def server(input: Inputs, output: Outputs, session: Session): def text(): return input.txt() - @render.text + @render.code def verb(): return input.txt() - @render.text + @render.code def verb_no_placeholder(): return input.txt() diff --git a/shiny/api-examples/popover/app-core.py b/shiny/api-examples/popover/app-core.py index e8d76682eb..8f41eb1026 100644 --- a/shiny/api-examples/popover/app-core.py +++ b/shiny/api-examples/popover/app-core.py @@ -31,7 +31,7 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def plot_txt(): return f"" diff --git a/shiny/api-examples/sidebar/app-core-dynamic.py b/shiny/api-examples/sidebar/app-core-dynamic.py index 50abf99483..75a9fc0452 100644 --- a/shiny/api-examples/sidebar/app-core-dynamic.py +++ b/shiny/api-examples/sidebar/app-core-dynamic.py @@ -61,7 +61,7 @@ def sidebar_dynamic_container(): ui.output_code("state_dynamic"), ) - @render.text + @render.code def state_dynamic(): return f"input.sidebar_dynamic(): {input.sidebar_dynamic()}" diff --git a/shiny/api-examples/sidebar/app-core.py b/shiny/api-examples/sidebar/app-core.py index 4971707008..421d1b2811 100644 --- a/shiny/api-examples/sidebar/app-core.py +++ b/shiny/api-examples/sidebar/app-core.py @@ -29,19 +29,19 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def state_left(): return f"input.sidebar_left(): {input.sidebar_left()}" - @render.text + @render.code def state_right(): return f"input.sidebar_right(): {input.sidebar_right()}" - @render.text + @render.code def state_closed(): return f"input.sidebar_closed(): {input.sidebar_closed()}" - @render.text + @render.code def state_always(): return f"input.sidebar_always(): {input.sidebar_always()}" diff --git a/shiny/api-examples/template/app-core.py b/shiny/api-examples/template/app-core.py index 0d43aafd2d..412115e45e 100644 --- a/shiny/api-examples/template/app-core.py +++ b/shiny/api-examples/template/app-core.py @@ -8,7 +8,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core-local.py b/shiny/api-examples/theme/app-core-local.py index 78ecdac931..281a7506c2 100644 --- a/shiny/api-examples/theme/app-core-local.py +++ b/shiny/api-examples/theme/app-core-local.py @@ -18,7 +18,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core-remote.py b/shiny/api-examples/theme/app-core-remote.py index e7bb73df84..32cfc690da 100644 --- a/shiny/api-examples/theme/app-core-remote.py +++ b/shiny/api-examples/theme/app-core-remote.py @@ -16,7 +16,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core-shinyswatch.py b/shiny/api-examples/theme/app-core-shinyswatch.py index 38b7fb542c..5dea033455 100644 --- a/shiny/api-examples/theme/app-core-shinyswatch.py +++ b/shiny/api-examples/theme/app-core-shinyswatch.py @@ -17,7 +17,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core.py b/shiny/api-examples/theme/app-core.py index 961e5bca5d..03ec10a5ef 100644 --- a/shiny/api-examples/theme/app-core.py +++ b/shiny/api-examples/theme/app-core.py @@ -18,7 +18,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/update_sidebar/app-core.py b/shiny/api-examples/update_sidebar/app-core.py index 74084c4462..a868dd99c6 100644 --- a/shiny/api-examples/update_sidebar/app-core.py +++ b/shiny/api-examples/update_sidebar/app-core.py @@ -22,7 +22,7 @@ def _(): def _(): ui.update_sidebar("sidebar", show=False) - @render.text + @render.code def state(): return f"input.sidebar(): {input.sidebar()}" diff --git a/shiny/templates/app/01-basic-app/app-core.py b/shiny/templates/app/01-basic-app/app-core.py index 0d43aafd2d..412115e45e 100644 --- a/shiny/templates/app/01-basic-app/app-core.py +++ b/shiny/templates/app/01-basic-app/app-core.py @@ -8,7 +8,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/ui/_output.py b/shiny/ui/_output.py index 4dedbd0e2d..49736dc20a 100644 --- a/shiny/ui/_output.py +++ b/shiny/ui/_output.py @@ -10,12 +10,11 @@ "output_ui", ) -import warnings from typing import Optional from htmltools import Tag, TagAttrValue, TagFunction, css, div, tags -from .._deprecated import ShinyDeprecationWarning +from .._deprecated import warn_deprecated from .._docstring import add_example, no_example from ..module import resolve_id from ..types import MISSING, MISSING_TYPE @@ -304,7 +303,7 @@ def output_code(id: str, placeholder: bool = True) -> Tag: -------- * :class:`~shiny.render.text` * :func:`~shiny.ui.output_text` - * :func:`~shiny.ui.output_text_verbatim` + * :func:`~shiny.ui.output_code` Example ------- @@ -318,7 +317,7 @@ def output_code(id: str, placeholder: bool = True) -> Tag: @add_example(ex_dir="../api-examples/input_text") def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: """ - Create a output container for some text. + Deprecated. Create a output container for some text. Place a :class:`~shiny.render.text` result in the user interface. Differs from :func:`~shiny.ui.output_text` in that it wraps the text in a @@ -341,6 +340,7 @@ def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: See Also -------- * :class:`~shiny.render.text` + * :class:`~shiny.render.code` * :func:`~shiny.ui.output_text` Example @@ -348,12 +348,10 @@ def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: See :func:`~shiny.ui.output_text` """ - warnings.warn( - "`ui.output_text_verbatim()` is deprecated. " - "Please use `ui.output_text()` if you want to create an output container for some text, " - "or `ui.output_code()` if you want to create an output container for code (monospaced text).", - category=ShinyDeprecationWarning, - stacklevel=2, + warn_deprecated( + "`ui.output_text_verbatim()` was deprecated in v1.6.0." + "Please use `ui.output_text()` / `@render.text` to create an output container for plain text " + "or `ui.output_code()` / `@render.code` to create an output container for monospaced text." ) cls = "shiny-text-output" + (" noplaceholder" if not placeholder else "") diff --git a/tests/playwright/examples/example_apps.py b/tests/playwright/examples/example_apps.py index 112d4e869e..ce31d30022 100644 --- a/tests/playwright/examples/example_apps.py +++ b/tests/playwright/examples/example_apps.py @@ -91,8 +91,6 @@ def get_apps(path: str) -> typing.List[str]: "FutureWarning: use_inf_as_na option is deprecated", "pd.option_context('mode.use_inf_as_na", # continutation of line above, "RuntimeWarning: invalid value encountered in dot", # some groups didn't have enough data points to create a meaningful line - # output_text_verbatim deprecation: https://github.com/posit-dev/py-shiny/pull/2097 - "ShinyDeprecationWarning: `ui.output_text_verbatim()` is deprecated.", ] app_allow_js_errors: typing.Dict[str, typing.List[str]] = { "examples/brownian": ["Failed to acquire camera feed:"], diff --git a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py index 08b2fd4136..72d283814f 100644 --- a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py +++ b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py @@ -43,7 +43,7 @@ def slider_with_reset_server( max: Optional[datetime.datetime] = None, value: Any = None, ): - @render.text + @render.code def txt(): if isinstance(input.times(), (tuple, list)): return " - ".join([str(x) for x in input.times()]) diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/app.py b/tests/playwright/shiny/bugs/0696-resolve-id/app.py index be56e6de29..368e7e8fb1 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/app.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/app.py @@ -200,7 +200,7 @@ def ui_navs(label: str) -> list[ui._navs.NavPanel]: "Image (Changes w/ `input.radio_buttons()`)", ui.output_image("out_image", height="180px"), ), - ("Text Verbatim", ui.output_code("out_text_verbatim")), + ("Code", ui.output_code("out_code")), ("Text", ui.output_text("out_text")), ("UI", ui.output_ui("out_ui")), ) @@ -244,8 +244,8 @@ def out_data_frame(): def out_text(): return f"Output text content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" - @render.text - def out_text_verbatim(): + @render.code + def out_code(): return f"Output text verbatim content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" @render.ui diff --git a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py index 711f3f8cd8..1a62bfa20f 100644 --- a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py +++ b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py @@ -16,11 +16,11 @@ def server(input: Inputs): def df1(): return render.DataGrid(df(), selection_mode="rows") - @render.text + @render.code def selected_rows(): return f"Input selected rows: {input.df1_selected_rows()}" - @render.text + @render.code def cell_selection(): return f"Cell selection rows: {df1.cell_selection()['rows']}" diff --git a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py index ffba1d741e..35343a84ba 100644 --- a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py +++ b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py @@ -35,7 +35,7 @@ def _(): ) df.set(new_df) - @render.text + @render.code def number_of_selected_rows(): df_selected = df1.data_view(selected=True) return f"Selected rows: {len(df_selected)}" diff --git a/tests/playwright/shiny/components/busy_indicators/app.py b/tests/playwright/shiny/components/busy_indicators/app.py index 287d790d69..25516b0e5d 100644 --- a/tests/playwright/shiny/components/busy_indicators/app.py +++ b/tests/playwright/shiny/components/busy_indicators/app.py @@ -77,7 +77,7 @@ def indicator_types_ui(): pulse=(selected_busy_indicator_type != "spinners"), ) - @render.text + @render.code def counter(): return str(rerender()) diff --git a/tests/playwright/shiny/components/data_frame/html_columns/app.py b/tests/playwright/shiny/components/data_frame/html_columns/app.py index 1e38475c7b..99060f2ced 100644 --- a/tests/playwright/shiny/components/data_frame/html_columns/app.py +++ b/tests/playwright/shiny/components/data_frame/html_columns/app.py @@ -151,11 +151,11 @@ def random_generator(): def server(input: Inputs, output: Outputs, session: Session) -> None: - @render.text + @render.code def pandas_test_cell_text(): return f"pandas_test_cell_value {input.pandas_test_cell_button()}" - @render.text + @render.code def polars_test_cell_text(): return f"polars_test_cell_value {input.polars_test_cell_button()}" diff --git a/tests/playwright/shiny/implicit-register/app.py b/tests/playwright/shiny/implicit-register/app.py index 8652f3c803..f71a0d033f 100644 --- a/tests/playwright/shiny/implicit-register/app.py +++ b/tests/playwright/shiny/implicit-register/app.py @@ -21,11 +21,11 @@ def server(input: Inputs, output: Outputs, session: Session): # does internally. @output(id="out2") - @render.text + @render.code def out1(): return "One" - @render.text + @render.code def out3(): return "Two" diff --git a/tests/playwright/shiny/inputs/input_file/app.py b/tests/playwright/shiny/inputs/input_file/app.py index 3690070182..4490af0daf 100644 --- a/tests/playwright/shiny/inputs/input_file/app.py +++ b/tests/playwright/shiny/inputs/input_file/app.py @@ -57,7 +57,7 @@ def summary(): # checkboxes return info_df.loc[:, input.stats()] - @render.text + @render.code def file2_info(): file2: typing.Union[typing.List["FileInfo"], None] = input.file2() if not file2: diff --git a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py index 437fb8add7..89865c83b6 100644 --- a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py +++ b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py @@ -65,19 +65,19 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def radio1_out(): return input.radio1() - @render.text + @render.code def radio2_out(): return input.radio2() - @render.text + @render.code def check1_out(): return input.check1() - @render.text + @render.code def check2_out(): return input.check2() diff --git a/tests/playwright/shiny/inputs/input_slider/app.py b/tests/playwright/shiny/inputs/input_slider/app.py index 30eadd0454..39fa22bf32 100644 --- a/tests/playwright/shiny/inputs/input_slider/app.py +++ b/tests/playwright/shiny/inputs/input_slider/app.py @@ -103,7 +103,7 @@ def make_output(id_num: int): name = f"txt{id_num}" @output(id=name) - @render.text + @render.code def _(): return input[f"s{id_num}"]() diff --git a/tests/playwright/shiny/inputs/input_text_update_on/app.py b/tests/playwright/shiny/inputs/input_text_update_on/app.py index 57da89fdfd..8addabc84e 100644 --- a/tests/playwright/shiny/inputs/input_text_update_on/app.py +++ b/tests/playwright/shiny/inputs/input_text_update_on/app.py @@ -91,19 +91,19 @@ def text_input_ui(update_on: Literal["change", "blur"] = "change"): @module.server def text_input_server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value_txt() -> str: return input.txt() - @render.text + @render.code def value_txtarea() -> str: return input.txtarea() - @render.text + @render.code def value_num() -> str: return str(input.num()) - @render.text + @render.code def value_pwd() -> str: return input.pwd() diff --git a/tests/playwright/shiny/server/reactive_event/app.py b/tests/playwright/shiny/server/reactive_event/app.py index c95a0e469c..98160fae58 100644 --- a/tests/playwright/shiny/server/reactive_event/app.py +++ b/tests/playwright/shiny/server/reactive_event/app.py @@ -18,11 +18,11 @@ def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def txt_immediate(): return input.btn_count() - @render.text + @render.code @reactive.event(input.btn_trigger) def txt_render_delayed(): return input.btn_count() @@ -32,7 +32,7 @@ def txt_render_delayed(): def delayed_btn_count() -> int: return input.btn_count() - @render.text + @render.code def txt_reactive_delayed(): return str(delayed_btn_count()) diff --git a/tests/playwright/shiny/session/flush/app.py b/tests/playwright/shiny/session/flush/app.py index 7f08741c77..a4ad429a6d 100644 --- a/tests/playwright/shiny/session/flush/app.py +++ b/tests/playwright/shiny/session/flush/app.py @@ -170,23 +170,23 @@ def reset(): cancel_on_ended_sync() cancel_on_ended_async() - @render.text + @render.code def btn_txt(): return str(input.btn()) - @render.text + @render.code def all_txt(): return str(all_vals.get()) - @render.text + @render.code def flush_txt(): return str(flush_vals.get()) - @render.text + @render.code def flushed_txt(): return str(flushed_vals.get()) - @render.text + @render.code def session_end_txt(): return str(session_ended_messages) From 5d6a1fd57c54cdc3f41a773b7efe852dd926ef09 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 16 Oct 2025 22:25:19 -0700 Subject: [PATCH 6/6] Update output code label and test expectation Changed the output label from 'Output text verbatim content' to 'Output Code content' in the app and updated the corresponding test to match the new label and output type. --- tests/playwright/shiny/bugs/0696-resolve-id/app.py | 2 +- .../shiny/bugs/0696-resolve-id/test_0696_resolve_id.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/app.py b/tests/playwright/shiny/bugs/0696-resolve-id/app.py index 368e7e8fb1..15478e8759 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/app.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/app.py @@ -246,7 +246,7 @@ def out_text(): @render.code def out_code(): - return f"Output text verbatim content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" + return f"Output Code content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" @render.ui def out_ui(): diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py b/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py index 1fb249eb59..7b18a2cc41 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py @@ -30,8 +30,8 @@ def resolve_id(id: str): controller.OutputText(page, resolve_id("out_text")).expect_value( f"Output text content. `input.radio_buttons()`: `{letter}`" ) - controller.OutputTextVerbatim(page, resolve_id("out_text_verbatim")).expect_value( - f"Output text verbatim content. `input.radio_buttons()`: `{letter}`" + controller.OutputCode(page, resolve_id("out_code")).expect_value( + f"Output Code content. `input.radio_buttons()`: `{letter}`" ) controller.OutputTable(page, resolve_id("out_table")).expect_nrow(count + 1)