Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Mar 4, 2025
1 parent a798507 commit 2d6af57
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
7 changes: 4 additions & 3 deletions shiny/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ async def _on_root_request_cb(self, request: Request) -> Response:
# TODO: Barret implement how to get bookmark_store value
# bookmarkStore <- getShinyOption("bookmarkStore", default = "disable")
print("TODO: Figure this out")
bookmark_store: str = "disable"
bookmark_store: str = "query"
bookmark_store: str = str("disable")
bookmark_store: str = str("query")

if bookmark_store == "disable":
restore_ctx = RestoreContext()
Expand All @@ -389,7 +389,8 @@ async def _on_root_request_cb(self, request: Request) -> Response:
if cur_restore_ctx is not None and cur_restore_ctx.active:
# TODO: See ?enableBookmarking
warnings.warn(
"Trying to restore saved app state, but UI code must be a function for this to work!"
"Trying to restore saved app state, but UI code must be a function for this to work!",
stacklevel=1,
)

ui = self.ui
Expand Down
2 changes: 0 additions & 2 deletions shiny/bookmark/_bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,6 @@ async def root_state_on_save(state: ShinySaveState) -> None:
# If onBookmarked callback was provided, invoke it; if not call
# the default.
if self._on_bookmarked_callbacks.count() > 0:
from ..session import session_context

with session_context(self._session_root):
await self._on_bookmarked_callbacks.invoke(full_url)
else:
Expand Down
34 changes: 18 additions & 16 deletions shiny/bookmark/_restore_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,21 @@ async def from_query_string(query_string: str) -> "RestoreContext":

return res_ctx

def set(
self,
*,
active: bool = False,
init_error_msg: str | None = None,
input_: dict[str, Any] = {},
values: dict[str, Any] = {},
dir_: Path | None = None,
) -> None:
self.active = active
self._init_error_msg = init_error_msg
self.input = RestoreInputSet()
self.input._values = input_
self.values = values
self.dir = dir_
# def set(
# self,
# *,
# active: bool = False,
# init_error_msg: str | None = None,
# input_: dict[str, Any] = {},
# values: dict[str, Any] = {},
# dir_: Path | None = None,
# ) -> None:
# self.active = active
# self._init_error_msg = init_error_msg
# self.input = RestoreInputSet()
# self.input._values = input_
# self.values = values
# self.dir = dir_

# This should be called before a restore context is popped off the stack.
def flush_pending(self) -> None:
Expand Down Expand Up @@ -258,7 +258,9 @@ async def _decode_state_qs(self, query_string: str) -> None:
elif storing_to == "values":
value_vals[qs_key] = from_json_str(qs_value)
except Exception as e:
warnings.warn(f'Failed to parse URL parameter "{qs_key}"')
warnings.warn(
f'Failed to parse URL parameter "{qs_key}"', stacklevel=3
)
print(e, storing_to, qs_key, qs_value)

self.input = RestoreInputSet(input_vals)
Expand Down
2 changes: 1 addition & 1 deletion shiny/bookmark/_save_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .._utils import private_random_id
from ..reactive import isolate
from ._bookmark_state import BookmarkState
from ._bookmark_state import BookmarkState, BookmarkStateLocal
from ._utils import is_hosted, to_json_str

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions shiny/express/_stub_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .._namespaces import Id, ResolvedId, Root
from ..bookmark import BookmarkExpressStub
from ..session import Inputs, Outputs, Session
from ..session._session import SessionProxy

if TYPE_CHECKING:
from ..session._session import DownloadHandler, DynamicRouteHandler, RenderedDeps
Expand Down
14 changes: 9 additions & 5 deletions shiny/session/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
from ..bookmark import BookmarkApp, BookmarkProxy
from ..http_staticfiles import FileResponse
from ..input_handler import input_handlers
from ..reactive import Effect_, Value, effect, isolate
from ..reactive import Effect_, Value, effect
from ..reactive import flush as reactive_flush
from ..reactive import isolate
from ..reactive._core import lock
from ..reactive._core import on_flushed as reactive_on_flushed
from ..render.renderer import Renderer, RendererT
Expand Down Expand Up @@ -639,11 +640,14 @@ def verify_state(expected_state: ConnectionState) -> None:
verify_state(ConnectionState.Start)

# BOOKMARKS!
self.bookmark._restore_context = (
await RestoreContext.from_query_string(
message_obj["data"][".clientdata_url_search"]
if ".clientdata_url_search" in message_obj["data"]:
self.bookmark._restore_context = (
await RestoreContext.from_query_string(
message_obj["data"][".clientdata_url_search"]
)
)
)
else:
self.bookmark._restore_context = RestoreContext()

# When a reactive flush occurs, flush the session's outputs,
# errors, etc. to the client. Note that this is
Expand Down

0 comments on commit 2d6af57

Please sign in to comment.