diff --git a/shiny/ui/_theme.py b/shiny/ui/_theme.py index 5225d8b1..d0fb6316 100644 --- a/shiny/ui/_theme.py +++ b/shiny/ui/_theme.py @@ -32,13 +32,6 @@ from ._utils import path_pkg_www T = TypeVar("T", bound="Theme") -SassImporterReturnValue = Union["tuple[str]", "tuple[str, str]", "tuple[str, str, str]"] -SassImporterFunction = Union[ - Callable[[str], SassImporterReturnValue], - Callable[[str, str], SassImporterReturnValue], -] - - class SassCompileArgs(TypedDict): output_style: NotRequired[Literal["nested", "expanded", "compact", "compressed"]] source_comments: NotRequired[bool] @@ -50,7 +43,7 @@ class SassCompileArgs(TypedDict): precision: NotRequired[int] custom_functions: NotRequired[Any] # not worth the effort, it's a complicated type indented: NotRequired[bool] - importers: NotRequired[Iterable[tuple[int, SassImporterFunction]] | None] + importers: NotRequired[Any] # not worth the effort, it's a complicated type theme_temporary_directories: set[tempfile.TemporaryDirectory[str]] = set() @@ -416,16 +409,23 @@ class Theme: check_libsass_installed() import sass - if compile_args is None: - compile_args = {"output_style": "compressed"} + args: SassCompileArgs = {} if compile_args is None else compile_args + + if "include_paths" in args: + raise ValueError( + "The 'include_paths' argument is not allowed in 'compile_args'. " + "Use the 'include_paths' argument of the Theme constructor instead.", + ) + + args: SassCompileArgs = { + "output_style": "compressed", + "include_paths": self._include_paths, + **args, + } - self._css = cast( - str, - sass.compile( - string=self.to_sass(), - include_paths=self._include_paths, - **compile_args, # type: ignore - ), + self._css = sass.compile( + string=self.to_sass(), + **args, ) return self._css