diff --git a/reflex/components/datadisplay/shiki_code_block.py b/reflex/components/datadisplay/shiki_code_block.py index cf04e6f9a..4d47f4c19 100644 --- a/reflex/components/datadisplay/shiki_code_block.py +++ b/reflex/components/datadisplay/shiki_code_block.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections import defaultdict -from typing import Any, Literal, Optional +from typing import Any, Literal, Optional, Union from reflex.base import Base from reflex.components.component import Component, ComponentNamespace @@ -382,13 +382,15 @@ class ShikiCodeBlock(Component): theme: Var[LiteralCodeTheme] = Var.create("one-light") # The set of themes to use for different modes. - themes: Var[list[dict[str, Any]] | dict[str, str]] + themes: Var[Union[list[dict[str, Any]], dict[str, str]]] # The code to display. code: Var[str] # The transformers to use for the syntax highlighter. - transformers: Var[list[ShikiBaseTransformers | dict[str, Any]]] = Var.create([]) + transformers: Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]] = Var.create( + [] + ) @classmethod def create( @@ -552,9 +554,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock): props["transformers"] = [ShikiJsTransformer()] if show_line_numbers: - line_style = LINE_NUMBER_STYLING.copy() - line_style.update(props.get("style", {})) - props["style"] = line_style + props["style"] = {**LINE_NUMBER_STYLING, **props.get("style", {})} theme = props.pop("theme", None) props["theme"] = props["theme"] = ( diff --git a/reflex/components/datadisplay/shiki_code_block.pyi b/reflex/components/datadisplay/shiki_code_block.pyi index 98c6b6749..e642cddac 100644 --- a/reflex/components/datadisplay/shiki_code_block.pyi +++ b/reflex/components/datadisplay/shiki_code_block.pyi @@ -9,7 +9,6 @@ from reflex.base import Base from reflex.components.component import Component, ComponentNamespace from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.utils.imports import ImportDict from reflex.vars.base import Var from reflex.vars.function import FunctionStringVar @@ -309,12 +308,12 @@ LiteralCodeTheme = Literal[ class ShikiBaseTransformers(Base): library: str fns: list[FunctionStringVar] - style: Style | None + style: Optional[Style] class ShikiJsTransformer(ShikiBaseTransformers): library: str fns: list[FunctionStringVar] - style: Style | None + style: Optional[Style] class ShikiCodeBlock(Component): @overload @@ -947,7 +946,7 @@ class ShikiCodeBlock(Component): """ ... - def add_imports(self) -> ImportDict | list[ImportDict]: ... + def add_imports(self) -> dict[str, list[str]]: ... @classmethod def create_transformer( cls, library: str, fns: list[str]