Skip to content

Commit 23cbe34

Browse files
cpsievertclaude
andauthored
fix: remove unnecessary run_coro_sync() hack. (#219)
Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 6424af5 commit 23cbe34

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ["3.9", "3.10", "3.11", "3.12"]
16+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1717
fail-fast: false
1818

1919
steps:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.1] - 2026-01-22
9+
10+
* Fixed an issue where anywidget-based widgets (like plotly) failed to initialize with `websockets>=16.0`. (#218)
11+
812
## [0.7.0] - 2025-07-14
913

1014
* `datetime.date()` values are properly JSON serialized. (#204)

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ classifiers =
1515
Intended Audience :: Developers
1616
License :: OSI Approved :: MIT License
1717
Natural Language :: English
18-
Programming Language :: Python :: 3.9
1918
Programming Language :: Python :: 3.10
2019
Programming Language :: Python :: 3.11
2120
Programming Language :: Python :: 3.12
21+
Programming Language :: Python :: 3.13
22+
Programming Language :: Python :: 3.14
2223
project_urls =
2324
Bug Tracker = https://github.com/rstudio/py-shinywidgets/issues
2425
Documentation = https://github.com/rstudio/py-shinywidgets/
2526
Source Code = https://github.com/rstudio/py-shinywidgets/
2627

2728
[options]
28-
python_requires = >=3.9
29+
python_requires = >=3.10
2930
packages = find:
3031
test_suite = tests
3132
include_package_data = True
@@ -46,8 +47,7 @@ test =
4647
pytest>=6.2.4
4748
dev =
4849
black>=23.1.0
49-
flake8==3.9.2;python_version<="3.7"
50-
flake8>=6.0.0;python_version>"3.7"
50+
flake8>=6.0.0
5151
isort>=5.11.2
5252
pyright>=1.1.284
5353
wheel

shinywidgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Carson Sievert"""
44
__email__ = "[email protected]"
5-
__version__ = "0.7.0"
5+
__version__ = "0.7.1"
66

77
from ._as_widget import as_widget
88
from ._dependencies import bokeh_dependency

shinywidgets/_comm.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from dataclasses import dataclass
33
from typing import Callable, Dict, List, Optional
44

5-
from shiny._utils import run_coro_hybrid
65
from shiny.session import get_current_session
76

87
from ._serialization import json_packer
@@ -46,7 +45,7 @@ def __init__(
4645
data: DataType = None,
4746
metadata: MetadataType = None,
4847
buffers: BufferType = None,
49-
**keys: object
48+
**keys: object,
5049
) -> None:
5150
self.comm_id = comm_id
5251
self.comm_manager = comm_manager
@@ -58,7 +57,7 @@ def open(
5857
data: DataType = None,
5958
metadata: MetadataType = None,
6059
buffers: BufferType = None,
61-
**keys: object
60+
**keys: object,
6261
) -> None:
6362
self.comm_manager.register_comm(self)
6463
try:
@@ -69,7 +68,7 @@ def open(
6968
buffers=buffers,
7069
target_name=self.target_name,
7170
target_module=None,
72-
**keys
71+
**keys,
7372
)
7473
self._closed = False
7574
except Exception:
@@ -120,7 +119,7 @@ def _publish_msg(
120119
data: DataType = None,
121120
metadata: MetadataType = None,
122121
buffers: BufferType = None,
123-
**keys: object
122+
**keys: object,
124123
) -> None:
125124
data = {} if data is None else data
126125
metadata = {} if metadata is None else metadata
@@ -166,10 +165,8 @@ def _publish_msg(
166165

167166
msg_txt = json_packer(msg)
168167

169-
# In theory, it seems that this send could maybe be async (that we then asyncio.create_task() with),
170-
# but that might mean that messages are sent out of order, which is not what we want.
171-
def _send():
172-
run_coro_hybrid(session.send_custom_message(msg_type, msg_txt)) # type: ignore
168+
async def _send():
169+
await session.send_custom_message(msg_type, msg_txt) # type: ignore
173170

174171
# N.B., if messages are sent immediately, run_coro_sync() could fail with
175172
# 'async function yielded control; it did not finish in one iteration.'

shinywidgets/_render_widget_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,17 @@ class WidgetRenderContext:
235235
def __init__(self, output_id):
236236
self.session = require_active_session(None)
237237
self.output_id = output_id
238-
self._old_id = self.session.__dict__.get("__shinywidget_current_output_id")
238+
self._old_id = vars(self.session).get("__shinywidget_current_output_id")
239239

240240
def __enter__(self):
241-
self.session.__dict__["__shinywidget_current_output_id"] = self.output_id
241+
vars(self.session)["__shinywidget_current_output_id"] = self.output_id
242242
return self
243243

244244
def __exit__(self, exc_type, exc_value, traceback):
245-
self.session.__dict__["__shinywidget_current_output_id"] = self._old_id
245+
vars(self.session)["__shinywidget_current_output_id"] = self._old_id
246246
return False
247247

248248
@staticmethod
249249
def is_rendering_widget(session):
250-
id = session.__dict__.get("__shinywidget_current_output_id")
250+
id = vars(session).get("__shinywidget_current_output_id")
251251
return id is not None

0 commit comments

Comments
 (0)