Skip to content

Commit 3082912

Browse files
committed
Clean up comments
1 parent b89bc9e commit 3082912

File tree

11 files changed

+39
-40
lines changed

11 files changed

+39
-40
lines changed

shiny/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ async def fn_async(*args: P.args, **kwargs: P.kwargs) -> R:
281281
return fn_async
282282

283283

284-
# # TODO-barret-future; Q: Keep code?
284+
# # TODO: Barret - Future: Q: Keep code?
285285
# class WrapAsync(Generic[P, R]):
286286
# """
287287
# Make a function asynchronous.

shiny/bookmark/_bookmark.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@
1212
from ._restore_state import RestoreContextState
1313
from ._save_state import ShinySaveState
1414

15-
# TODO: bookmark button
16-
17-
# TODO:
15+
# TODO: Barret - Bookmark state
1816
# bookmark -> save/load interface
19-
# * √ base class
20-
# * √ local
21-
# save/load interface -> register interface
22-
# * implement; Q on approach!
17+
# * √ global hooks
18+
# * √ default local functions
19+
# save/load interface -> register functions
20+
# * `shiny.bookmark.globals`
2321
# register interface -> Make interface for Connect
24-
# * implement in Connect PR
22+
# * TODO: implement in Connect PR
2523
# bookmark -> save state
2624
# save state -> {inputs, values, exclude}
2725
# {inputs} -> custom serializer
28-
# √ Hook to `Inputs.set_serializer(id, fn)`
29-
# √ `Inputs._serialize()` to create a dict
26+
# * √ Hook to `Inputs.set_serializer(id, fn)`
27+
# * √ `Inputs._serialize()` to create a dict
3028
# {values} -> dict (where as in R is an environment)
31-
# √ values is a dict!
29+
# * √ values is a dict!
3230
# {exclude} -> Requires `session.setBookmarkExclude(names)`, `session.getBookmarkExclude()`
33-
# √ `session.bookmark_exclude: list[str]` value!
34-
# √ `session._get_bookmark_exclude()` & `session._bookmark_exclude_fn`
31+
# * √ `session.bookmark_exclude: list[str]` value!
32+
# * √ `session._get_bookmark_exclude()` & `session._bookmark_exclude_fn`
3533
# Using a `.bookmark_exclude = []` and `._get_bookmark_exclude()` helper that accesses a `._bookmark_exclude_fns` list of functions which return scoped bookmark excluded values
3634
# Enable bookmarking hooks:
3735
# * √ `session.bookmark_store`: `url`, `server`, `disable`
@@ -485,8 +483,6 @@ async def root_state_on_save(state: ShinySaveState) -> None:
485483
from ..ui._notification import notification_show
486484

487485
notification_show(msg, duration=None, type="error")
488-
# TODO: Barret - Remove this!
489-
raise RuntimeError("Error bookmarking state") from e
490486

491487

492488
class BookmarkProxy(Bookmark):

shiny/bookmark/_globals.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
from ..types import MISSING, MISSING_TYPE
77

88
# TODO: Barret: Q: Can we merge how bookmark dirs are saved / loaded?... it's the same directory! However, the save will return a possibly new path. Restoring will return an existing path.
9-
BookmarkStateSaveDir = Callable[[str], Awaitable[Path]]
10-
BookmarkStateLoadDir = Callable[[str], Awaitable[Path]]
11-
bookmark_state_save_dir: BookmarkStateSaveDir | MISSING_TYPE = MISSING
12-
bookmark_state_load_dir: BookmarkStateLoadDir | MISSING_TYPE = MISSING
9+
BookmarkSaveDir = Callable[[str], Awaitable[Path]]
10+
BookmarkLoadDir = Callable[[str], Awaitable[Path]]
11+
12+
bookmark_save_dir: BookmarkSaveDir | MISSING_TYPE = MISSING
13+
bookmark_load_dir: BookmarkLoadDir | MISSING_TYPE = MISSING
1314

1415
BookmarkStore = Literal["url", "server", "disable"]
15-
# TODO: barret - Q: Should we have a `enable_bookmarking(store: BookmarkStore)` function?
16+
# TODO: Barret - Q: Should we have a `enable_bookmarking(store: BookmarkStore)` function?
1617
bookmark_store: BookmarkStore = "disable"
18+
19+
20+
# TODO: Barret; Q: I feel like there could be a `@shiny.globals.on_session_start` decorator that would allow us to set these values.

shiny/bookmark/_restore_state.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from . import _globals as bookmark_globals
1414
from ._bookmark_state import local_load_dir
15-
from ._globals import BookmarkStateLoadDir
15+
from ._globals import BookmarkLoadDir
1616
from ._utils import from_json_str, is_hosted
1717

1818

@@ -186,13 +186,13 @@ async def _load_state_qs(self, query_string: str) -> None:
186186

187187
id = id[0]
188188

189-
load_bookmark_fn: BookmarkStateLoadDir | None = None
190-
if not isinstance(bookmark_globals.bookmark_state_load_dir, MISSING_TYPE):
191-
load_bookmark_fn = bookmark_globals.bookmark_state_load_dir
189+
load_bookmark_fn: BookmarkLoadDir | None = None
190+
if not isinstance(bookmark_globals.bookmark_load_dir, MISSING_TYPE):
191+
load_bookmark_fn = bookmark_globals.bookmark_load_dir
192192

193193
if load_bookmark_fn is None:
194194
if is_hosted():
195-
# TODO: Barret
195+
# TODO: Barret; Implement Connect's `bookmark_load_dir` function
196196
raise NotImplementedError(
197197
"The hosting environment does not support server-side bookmarking."
198198
)

shiny/bookmark/_save_state.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from ..types import MISSING_TYPE
1111
from . import _globals as bookmark_globals
1212
from ._bookmark_state import local_save_dir
13-
from ._globals import BookmarkStateSaveDir
13+
from ._globals import BookmarkSaveDir
1414
from ._utils import is_hosted, to_json_str
1515

16-
# TODO: barret - Set / Load SaveState for Connect. Ex: Connect https://github.com/posit-dev/connect/blob/8de330aec6a61cf21e160b5081d08a1d3d7e8129/R/connect.R#L915
16+
# TODO: Barret - Set / Load SaveState for Connect. Ex: Connect https://github.com/posit-dev/connect/blob/8de330aec6a61cf21e160b5081d08a1d3d7e8129/R/connect.R#L915
1717
# Might need to have independent save/load functions to register to avoid a class constructor
1818

1919

@@ -76,13 +76,13 @@ async def _save_state(self) -> str:
7676
# to `self.dir`.
7777

7878
# This will be defined by the hosting environment if it supports bookmarking.
79-
save_bookmark_fn: BookmarkStateSaveDir | None = None
80-
if not isinstance(bookmark_globals.bookmark_state_save_dir, MISSING_TYPE):
81-
save_bookmark_fn = bookmark_globals.bookmark_state_save_dir
79+
save_bookmark_fn: BookmarkSaveDir | None = None
80+
if not isinstance(bookmark_globals.bookmark_save_dir, MISSING_TYPE):
81+
save_bookmark_fn = bookmark_globals.bookmark_save_dir
8282

8383
if save_bookmark_fn is None:
8484
if is_hosted():
85-
# TODO: Barret
85+
# TODO: Barret; Implement `bookmark_save_dir` for Connect
8686
raise NotImplementedError(
8787
"The hosting environment does not support server-side bookmarking."
8888
)

shiny/bookmark/_serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ async def serializer_default(value: T, state_dir: Path | None) -> T:
2727
return value
2828

2929

30-
# TODO-barret; Integrate
30+
# TODO: Barret - Integrate
3131
def serializer_file_input(
3232
value: Any,
3333
state_dir: Path | None,
3434
) -> Any | Unserializable:
3535
if state_dir is None:
3636
return Unserializable()
3737

38-
# TODO: barret; Double check this logic!
38+
# TODO: Barret - Double check this logic!
3939

4040
# `value` is a data frame. When persisting files, we need to copy the file to
4141
# the persistent dir and then strip the original path before saving.

shiny/bookmark/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def is_hosted() -> bool:
1010
# Can't look at SHINY_PORT, as we already set it in shiny/_main.py's `run_app()`
1111

12-
# TODO: Support shinyapps.io or use `SHINY_PORT` how R-shiny did
12+
# TODO: Barret: Q: How to support shinyapps.io? Or use `SHINY_PORT` how R-shiny did
1313

1414
# Instead, looking for the presence of the environment variable that Connect sets
1515
# (*_Connect) or Shiny Server sets (SHINY_APP)

shiny/express/_stub_session.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ def __init__(self, ns: ResolvedId = Root):
4747

4848
self.bookmark = BookmarkExpressStub(self)
4949

50-
self.exclude = []
51-
self.store = "disable" # TODO: Is this correct?
52-
5350
def is_stub_session(self) -> Literal[True]:
5451
return True
5552

shiny/input_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ def _(value: str, name: ResolvedId, session: Session) -> str:
151151

152152

153153
# TODO: implement when we have bookmarking
154+
# TODO: Barret: Input handler for passwords
154155
@input_handlers.add("shiny.password")
155156
def _(value: str, name: ResolvedId, session: Session) -> str:
156157
return value
157158

158159

159160
# TODO: implement when we have bookmarking
161+
# TODO: Barret: Input handler for file inputs
160162
@input_handlers.add("shiny.file")
161163
def _(value: Any, name: ResolvedId, session: Session) -> Any:
162164
return value

shiny/session/_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ async def _serialize(
14571457
with reactive.isolate():
14581458

14591459
for key, value in self._map.items():
1460-
# TODO: Barret - Q: Should this be anything that starts with a "."?
1460+
# TODO: Barret - Q: Should this be ignoring any Input key that starts with a "."?
14611461
if key.startswith(".clientdata_"):
14621462
continue
14631463
if key == BOOKMARK_ID or key.endswith(

0 commit comments

Comments
 (0)