Skip to content

Commit b517a53

Browse files
committed
Value: Use MISSING as default value
1 parent 8ea3e26 commit b517a53

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

shiny/reactive/_reactives.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
# ==============================================================================
3131
class Value(Generic[T]):
3232
# These overloads are necessary so that the following hold:
33-
# - Value() is marked by the type checker as an error. It is also a run-time error.
34-
# - Value(MISSING) is marked by the type checker as an error, because the type T
35-
# is unknown. (It is not a run-time error.)
36-
# - Value[int](MISSING) works.
33+
# - Value() is marked by the type checker as an error, because the type T is
34+
# unknown. (It is not a run-time error.)
35+
# - Value[int]() works.
3736
# - Value[int](1) works.
3837
# - Value(1) works, with T is inferred to be int.
3938
@overload
40-
def __init__(self, value: MISSING_TYPE, *, read_only: bool = False) -> None:
39+
def __init__(
40+
self, value: MISSING_TYPE = MISSING, *, read_only: bool = False
41+
) -> None:
4142
...
4243

4344
@overload
@@ -47,7 +48,7 @@ def __init__(self, value: T, *, read_only: bool = False) -> None:
4748
# If `value` is MISSING, then `get()` will raise a SilentException, until a new
4849
# value is set. Calling `unset()` will set the value to MISSING.
4950
def __init__(
50-
self, value: Union[T, MISSING_TYPE], *, read_only: bool = False
51+
self, value: Union[T, MISSING_TYPE] = MISSING, *, read_only: bool = False
5152
) -> None:
5253
self._value: T = value
5354
self._read_only: bool = read_only

shiny/session/_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def __getitem__(self, key: str) -> Value[Any]:
556556
# dependencies on input values that haven't been received from client
557557
# yet.
558558
if key not in self._map:
559-
self._map[key] = Value(MISSING, read_only=True)
559+
self._map[key] = Value(read_only=True)
560560

561561
return self._map[key]
562562

0 commit comments

Comments
 (0)