Skip to content

Commit 9b7a62e

Browse files
committed
chore: Back to T | MISSING_TYPE = MISSING instead of Maybe[T] = MISSING
1 parent 4427769 commit 9b7a62e

File tree

4 files changed

+40
-41
lines changed

4 files changed

+40
-41
lines changed

shiny/express/ui/_cm_components.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from ... import ui
1010
from ..._docstring import add_example, no_example
11-
from ...types import DEPRECATED, MISSING, MISSING_TYPE, Maybe
11+
from ...types import DEPRECATED, MISSING, MISSING_TYPE
1212
from ...ui._accordion import AccordionPanel
1313
from ...ui._card import CardItem
1414
from ...ui._layout_columns import BreakpointsUser
@@ -1080,11 +1080,11 @@ def navset_bar(
10801080
navbar_options: Optional[NavbarOptions] = None,
10811081
fluid: bool = True,
10821082
# Deprecated ----
1083-
position: Maybe[NavbarOptionsPositionT] = DEPRECATED,
1084-
bg: Maybe[str | None] = DEPRECATED,
1085-
inverse: Maybe[bool] = DEPRECATED,
1086-
underline: Maybe[bool] = DEPRECATED,
1087-
collapsible: Maybe[bool] = DEPRECATED,
1083+
position: NavbarOptionsPositionT | MISSING_TYPE = DEPRECATED,
1084+
bg: str | None | MISSING_TYPE = DEPRECATED,
1085+
inverse: bool | MISSING_TYPE = DEPRECATED,
1086+
underline: bool | MISSING_TYPE = DEPRECATED,
1087+
collapsible: bool | MISSING_TYPE = DEPRECATED,
10881088
) -> RecallContextManager[NavSetBar]:
10891089
"""
10901090
Context manager for a set of nav items as a tabset inside a card container.

shiny/types.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from htmltools import TagChild
3232

3333
from ._docstring import add_example
34-
from ._typing_extensions import NotRequired, TypedDict, TypeIs
34+
from ._typing_extensions import NotRequired, TypedDict
3535

3636
if TYPE_CHECKING:
3737
from matplotlib.figure import Figure
@@ -46,15 +46,10 @@ class MISSING_TYPE:
4646

4747
MISSING: MISSING_TYPE = MISSING_TYPE()
4848
DEPRECATED: MISSING_TYPE = MISSING_TYPE() # A MISSING that communicates deprecation
49-
Maybe = Union[T, MISSING_TYPE]
5049

5150
ListOrTuple = Union[List[T], Tuple[T, ...]]
5251

5352

54-
def is_missing(x: Any) -> TypeIs[MISSING_TYPE]:
55-
return isinstance(x, MISSING_TYPE)
56-
57-
5853
# Information about a single file, with a structure like:
5954
# {'name': 'mtcars.csv', 'size': 1303, 'type': 'text/csv', 'datapath: '/...../mtcars.csv'}
6055
# The incoming data doesn't include 'datapath'; that field is added by the

shiny/ui/_navs.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .._docstring import add_example
2323
from .._namespaces import resolve_id_or_none
2424
from .._utils import private_random_int
25-
from ..types import DEPRECATED, MISSING, Maybe, NavSetArg, is_missing
25+
from ..types import DEPRECATED, MISSING, MISSING_TYPE, NavSetArg
2626
from ._bootstrap import column, row
2727
from ._card import CardItem, WrapperCallable, card, card_body, card_footer, card_header
2828
from ._html_deps_shinyverse import components_dependencies
@@ -1013,11 +1013,11 @@ class NavbarOptions:
10131013
def __init__(
10141014
self,
10151015
*,
1016-
position: Maybe[NavbarOptionsPositionT] = MISSING,
1017-
bg: Maybe[str | None] = MISSING,
1018-
theme: Maybe[NavbarOptionsThemeT] = MISSING,
1019-
underline: Maybe[bool] = MISSING,
1020-
collapsible: Maybe[bool] = MISSING,
1016+
position: NavbarOptionsPositionT | MISSING_TYPE = MISSING,
1017+
bg: str | None | MISSING_TYPE = MISSING,
1018+
theme: NavbarOptionsThemeT | MISSING_TYPE = MISSING,
1019+
underline: bool | MISSING_TYPE = MISSING,
1020+
collapsible: bool | MISSING_TYPE = MISSING,
10211021
**attrs: TagAttrValue,
10221022
):
10231023
self._is_default = {}
@@ -1037,7 +1037,7 @@ def __init__(
10371037
self.attrs = attrs
10381038

10391039
def _maybe_default(self, name: str, value: Any, default: Any):
1040-
if is_missing(value):
1040+
if isinstance(value, MISSING_TYPE):
10411041
self._is_default[name] = True
10421042
return default
10431043
return value
@@ -1070,11 +1070,11 @@ def __repr__(self):
10701070

10711071
@add_example()
10721072
def navbar_options(
1073-
position: Maybe[NavbarOptionsPositionT] = MISSING,
1074-
bg: Maybe[str | None] = MISSING,
1075-
theme: Maybe[NavbarOptionsThemeT] = MISSING,
1076-
underline: Maybe[bool] = MISSING,
1077-
collapsible: Maybe[bool] = MISSING,
1073+
position: NavbarOptionsPositionT | MISSING_TYPE = MISSING,
1074+
bg: str | None | MISSING_TYPE = MISSING,
1075+
theme: NavbarOptionsThemeT | MISSING_TYPE = MISSING,
1076+
underline: bool | MISSING_TYPE = MISSING,
1077+
collapsible: bool | MISSING_TYPE = MISSING,
10781078
**attrs: TagAttrValue,
10791079
) -> NavbarOptions:
10801080
"""
@@ -1120,11 +1120,11 @@ def navbar_options(
11201120

11211121
def navbar_options_resolve_deprecated(
11221122
options_user: Optional[NavbarOptions] = None,
1123-
position: Maybe[NavbarOptionsPositionT] = DEPRECATED,
1124-
bg: Maybe[str | None] = DEPRECATED,
1125-
inverse: Maybe[bool] = DEPRECATED,
1126-
underline: Maybe[bool] = DEPRECATED,
1127-
collapsible: Maybe[bool] = DEPRECATED,
1123+
position: NavbarOptionsPositionT | MISSING_TYPE = DEPRECATED,
1124+
bg: str | None | MISSING_TYPE = DEPRECATED,
1125+
inverse: bool | MISSING_TYPE = DEPRECATED,
1126+
underline: bool | MISSING_TYPE = DEPRECATED,
1127+
collapsible: bool | MISSING_TYPE = DEPRECATED,
11281128
fn_caller: str = "navset_bar",
11291129
) -> NavbarOptions:
11301130
options_user = options_user if options_user is not None else navbar_options()
@@ -1136,7 +1136,9 @@ def navbar_options_resolve_deprecated(
11361136
"collapsible": collapsible,
11371137
"underline": underline,
11381138
}
1139-
options_old = {k: v for k, v in options_old.items() if not is_missing(v)}
1139+
options_old = {
1140+
k: v for k, v in options_old.items() if not isinstance(v, MISSING_TYPE)
1141+
}
11401142

11411143
args_deprecated = list(options_old.keys())
11421144

@@ -1375,11 +1377,11 @@ def navset_bar(
13751377
navbar_options: Optional[NavbarOptions] = None,
13761378
fluid: bool = True,
13771379
# Deprecated -- v1.3.0 2025-01 ----
1378-
position: Maybe[NavbarOptionsPositionT] = DEPRECATED,
1379-
bg: Maybe[str | None] = DEPRECATED,
1380-
inverse: Maybe[bool] = DEPRECATED,
1381-
underline: Maybe[bool] = DEPRECATED,
1382-
collapsible: Maybe[bool] = DEPRECATED,
1380+
position: NavbarOptionsPositionT | MISSING_TYPE = DEPRECATED,
1381+
bg: str | None | MISSING_TYPE = DEPRECATED,
1382+
inverse: bool | MISSING_TYPE = DEPRECATED,
1383+
underline: bool | MISSING_TYPE = DEPRECATED,
1384+
collapsible: bool | MISSING_TYPE = DEPRECATED,
13831385
) -> NavSetBar:
13841386
"""
13851387
Render nav items as a navbar.

shiny/ui/_page.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from .._docstring import add_example, no_example
3333
from .._namespaces import resolve_id_or_none
34-
from ..types import DEPRECATED, MISSING, MISSING_TYPE, Maybe, NavSetArg
34+
from ..types import DEPRECATED, MISSING, MISSING_TYPE, NavSetArg
3535
from ._bootstrap import panel_title
3636
from ._html_deps_external import Theme, ThemeProvider, shiny_page_theme_deps
3737
from ._html_deps_py_shiny import page_output_dependency
@@ -175,11 +175,13 @@ def page_navbar(
175175
lang: Optional[str] = None,
176176
theme: Optional[str | Path | Theme | ThemeProvider] = None,
177177
# Deprecated -- v1.3.0 2025-01 ----
178-
position: Maybe[Literal["static-top", "fixed-top", "fixed-bottom"]] = DEPRECATED,
179-
bg: Maybe[str | None] = DEPRECATED,
180-
inverse: Maybe[bool] = DEPRECATED,
181-
underline: Maybe[bool] = DEPRECATED,
182-
collapsible: Maybe[bool] = DEPRECATED,
178+
position: (
179+
Literal["static-top", "fixed-top", "fixed-bottom"] | MISSING_TYPE
180+
) = DEPRECATED,
181+
bg: str | None | MISSING_TYPE = DEPRECATED,
182+
inverse: bool | MISSING_TYPE = DEPRECATED,
183+
underline: bool | MISSING_TYPE = DEPRECATED,
184+
collapsible: bool | MISSING_TYPE = DEPRECATED,
183185
) -> Tag:
184186
"""
185187
Create a page with a navbar and a title.

0 commit comments

Comments
 (0)