fix pyi and annotations
This commit is contained in:
parent
bee1ae15cf
commit
cdad1f9432
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Any, Literal, Optional
|
from typing import Any, Literal, Optional, Union
|
||||||
|
|
||||||
from reflex.base import Base
|
from reflex.base import Base
|
||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
@ -382,13 +382,15 @@ class ShikiCodeBlock(Component):
|
|||||||
theme: Var[LiteralCodeTheme] = Var.create("one-light")
|
theme: Var[LiteralCodeTheme] = Var.create("one-light")
|
||||||
|
|
||||||
# The set of themes to use for different modes.
|
# 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.
|
# The code to display.
|
||||||
code: Var[str]
|
code: Var[str]
|
||||||
|
|
||||||
# The transformers to use for the syntax highlighter.
|
# 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
|
@classmethod
|
||||||
def create(
|
def create(
|
||||||
@ -552,9 +554,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
|||||||
props["transformers"] = [ShikiJsTransformer()]
|
props["transformers"] = [ShikiJsTransformer()]
|
||||||
|
|
||||||
if show_line_numbers:
|
if show_line_numbers:
|
||||||
line_style = LINE_NUMBER_STYLING.copy()
|
props["style"] = {**LINE_NUMBER_STYLING, **props.get("style", {})}
|
||||||
line_style.update(props.get("style", {}))
|
|
||||||
props["style"] = line_style
|
|
||||||
|
|
||||||
theme = props.pop("theme", None)
|
theme = props.pop("theme", None)
|
||||||
props["theme"] = props["theme"] = (
|
props["theme"] = props["theme"] = (
|
||||||
|
@ -9,7 +9,6 @@ from reflex.base import Base
|
|||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
from reflex.event import EventHandler, EventSpec
|
from reflex.event import EventHandler, EventSpec
|
||||||
from reflex.style import Style
|
from reflex.style import Style
|
||||||
from reflex.utils.imports import ImportDict
|
|
||||||
from reflex.vars.base import Var
|
from reflex.vars.base import Var
|
||||||
from reflex.vars.function import FunctionStringVar
|
from reflex.vars.function import FunctionStringVar
|
||||||
|
|
||||||
@ -309,12 +308,12 @@ LiteralCodeTheme = Literal[
|
|||||||
class ShikiBaseTransformers(Base):
|
class ShikiBaseTransformers(Base):
|
||||||
library: str
|
library: str
|
||||||
fns: list[FunctionStringVar]
|
fns: list[FunctionStringVar]
|
||||||
style: Style | None
|
style: Optional[Style]
|
||||||
|
|
||||||
class ShikiJsTransformer(ShikiBaseTransformers):
|
class ShikiJsTransformer(ShikiBaseTransformers):
|
||||||
library: str
|
library: str
|
||||||
fns: list[FunctionStringVar]
|
fns: list[FunctionStringVar]
|
||||||
style: Style | None
|
style: Optional[Style]
|
||||||
|
|
||||||
class ShikiCodeBlock(Component):
|
class ShikiCodeBlock(Component):
|
||||||
@overload
|
@overload
|
||||||
@ -947,7 +946,7 @@ class ShikiCodeBlock(Component):
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def add_imports(self) -> ImportDict | list[ImportDict]: ...
|
def add_imports(self) -> dict[str, list[str]]: ...
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_transformer(
|
def create_transformer(
|
||||||
cls, library: str, fns: list[str]
|
cls, library: str, fns: list[str]
|
||||||
|
Loading…
Reference in New Issue
Block a user