Skip to content

Commit 9fcdb9a

Browse files
committed
Typing fixes
1 parent 446c8ac commit 9fcdb9a

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

shiny/_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from contextlib import AsyncExitStack, asynccontextmanager
77
from inspect import signature
88
from pathlib import Path
9-
from typing import Any, Callable, Optional, TypeVar, cast
9+
from typing import Any, Callable, Mapping, Optional, TypeVar, cast
1010

1111
import starlette.applications
1212
import starlette.exceptions
@@ -113,7 +113,7 @@ def __init__(
113113
Callable[[Inputs], None] | Callable[[Inputs, Outputs, Session], None] | None
114114
),
115115
*,
116-
static_assets: Optional[str | Path | dict[str, str | Path]] = None,
116+
static_assets: Optional[str | Path | Mapping[str, str | Path]] = None,
117117
debug: bool = False,
118118
) -> None:
119119
# Used to store callbacks to be called when the app is shutting down (according
@@ -143,7 +143,7 @@ def __init__(
143143
if static_assets is None:
144144
static_assets = {}
145145

146-
if isinstance(static_assets, dict):
146+
if isinstance(static_assets, Mapping):
147147
static_assets_map = {k: Path(v) for k, v in static_assets.items()}
148148
else:
149149
static_assets_map = {"/": Path(static_assets)}

shiny/express/_run.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import annotations
22

33
import ast
4-
import os
54
import sys
65
from pathlib import Path
7-
from typing import cast
6+
from typing import Mapping, cast
87

98
from htmltools import Tag, TagList
109

@@ -200,9 +199,7 @@ class AppOpts(TypedDict):
200199

201200
@no_example()
202201
def app_opts(
203-
static_assets: (
204-
str | os.PathLike[str] | dict[str, str | Path] | MISSING_TYPE
205-
) = MISSING,
202+
static_assets: str | Path | Mapping[str, str | Path] | MISSING_TYPE = MISSING,
206203
debug: bool | MISSING_TYPE = MISSING,
207204
):
208205
"""
@@ -230,7 +227,7 @@ def app_opts(
230227
return
231228

232229
if not isinstance(static_assets, MISSING_TYPE):
233-
if isinstance(static_assets, (str, os.PathLike)):
230+
if isinstance(static_assets, (str, Path)):
234231
static_assets = {"/": Path(static_assets)}
235232

236233
# Convert string values to Paths. (Need new var name to help type checker.)

0 commit comments

Comments
 (0)