Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mayagbarnes committed Oct 6, 2023
1 parent b7253fb commit 6964324
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/streamlit/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

"""Platform module."""

from streamlit.errors import NoSessionContext

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'NoSessionContext' is not used.
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
from streamlit.runtime.scriptrunner import get_script_run_ctx


def post_parent_message(message: str) -> str:
def post_parent_message(message: str) -> None:
"""
Sends a string message to the parent window (when host configuration allows).
"""
ctx = get_script_run_ctx()
post_msg = ForwardMsg()
post_msg.parent_message.message = message
ctx.enqueue(post_msg)
if ctx is None:
return

fwd_msg = ForwardMsg()
fwd_msg.parent_message.message = message
ctx.enqueue(fwd_msg)
6 changes: 5 additions & 1 deletion lib/tests/streamlit/web/server/routes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

from streamlit.runtime.forward_msg_cache import ForwardMsgCache, populate_hash_if_needed
from streamlit.runtime.runtime_util import serialize_forward_msg
from streamlit.web.server.routes import _DEFAULT_ALLOWED_MESSAGE_ORIGINS
from streamlit.web.server.routes import (
_DEFAULT_ALLOWED_MESSAGE_ORIGINS,
_DEFAULT_HOST_CONFIG,
)
from streamlit.web.server.server import (
HEALTH_ENDPOINT,
HOST_CONFIG_ENDPOINT,
Expand Down Expand Up @@ -191,6 +194,7 @@ def test_allowed_message_origins(self):
{
"allowedOrigins": _DEFAULT_ALLOWED_MESSAGE_ORIGINS,
"useExternalAuthToken": False,
"hostConfig": _DEFAULT_HOST_CONFIG,
},
response_body,
)
Expand Down

0 comments on commit 6964324

Please sign in to comment.