Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat 1.38.0 #233

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
streamlit-version: [null]
include:
# Test with streamlit <1.4.0 and >=1.4.0. See https://github.com/whitphx/streamlit-server-state/issues/64
Expand All @@ -39,6 +39,9 @@ jobs:
# Test with streamlit >=1.18.0. See https://github.com/whitphx/streamlit-server-state/issues/171
- python-version: 3.9
streamlit-version: 1.18.0
# Test with streamlit >=1.38.0. See https://github.com/whitphx/streamlit-server-state/pull/232
- python-version: 3.9
streamlit-version: 1.38.0

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion app_chat_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if "rooms" not in server_state:
server_state["rooms"] = []

rooms = server_state["rooms"]
rooms: list[str] = server_state["rooms"]

room = st.sidebar.radio("Select room", rooms)

Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[mypy]
python_version = 3.8
python_version = 3.9
ignore_missing_imports = True
79 changes: 43 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions streamlit_server_state/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,36 @@


try:
from streamlit.runtime.scriptrunner.script_run_context import (
from streamlit.runtime.scriptrunner_utils.script_run_context import (
SCRIPT_RUN_CONTEXT_ATTR_NAME,
ScriptRunContext,
)
except ModuleNotFoundError:
# streamlit < 1.12.0
# streamlit < 1.38.0
try:
from streamlit.scriptrunner.script_run_context import ( # type: ignore
from streamlit.runtime.scriptrunner.script_run_context import ( # type: ignore
SCRIPT_RUN_CONTEXT_ATTR_NAME,
ScriptRunContext,
)
except ModuleNotFoundError:
# streamlit < 1.8
# streamlit < 1.12.0
try:
from streamlit.script_run_context import ( # type: ignore
from streamlit.scriptrunner.script_run_context import ( # type: ignore
SCRIPT_RUN_CONTEXT_ATTR_NAME,
ScriptRunContext,
)
except ModuleNotFoundError:
from streamlit.report_thread import ( # type: ignore # isort:skip
REPORT_CONTEXT_ATTR_NAME as SCRIPT_RUN_CONTEXT_ATTR_NAME,
ReportContext as ScriptRunContext,
)
# streamlit < 1.8
try:
from streamlit.script_run_context import ( # type: ignore
SCRIPT_RUN_CONTEXT_ATTR_NAME,
ScriptRunContext,
)
except ModuleNotFoundError:
from streamlit.report_thread import ( # type: ignore # isort:skip
REPORT_CONTEXT_ATTR_NAME as SCRIPT_RUN_CONTEXT_ATTR_NAME,
ReportContext as ScriptRunContext,
)

try:
from streamlit.runtime.scriptrunner import get_script_run_ctx
Expand Down
Loading