Skip to content

Commit

Permalink
add Component.library str type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-bartscher committed Mar 5, 2024
1 parent f44d0ed commit 16b7bae
Show file tree
Hide file tree
Showing 29 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion reflex/components/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class NextDocumentLib(Component):
"""Root document components."""

library = "next/document"
library: str = "next/document"


class Html(NextDocumentLib):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/base/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
class Fragment(Component):
"""A React fragment to return multiple components from a function without wrapping it in a container."""

library = "react"
library: str = "react"
tag: str = "Fragment"
2 changes: 1 addition & 1 deletion reflex/components/base/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class NextHeadLib(Component):
"""Header components."""

library = "next/head"
library: str = "next/head"


class Head(NextHeadLib, MemoizationLeaf):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/base/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Script(Component):
HTML <script> tag which does not work when rendering a component.
"""

library = "next/script"
library: str = "next/script"
tag: str = "Script"
is_default: bool = True

Expand Down
4 changes: 2 additions & 2 deletions reflex/components/chakra/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ChakraComponent(Component):
"""A component that wraps a Chakra component."""

library = "@chakra-ui/[email protected]"
library: str = "@chakra-ui/[email protected]"
lib_dependencies: List[str] = [
"@chakra-ui/[email protected]",
"[email protected]",
Expand Down Expand Up @@ -92,7 +92,7 @@ def _get_app_wrap_components() -> dict[tuple[int, str], Component]:
class ChakraColorModeProvider(Component):
"""Next-themes integration for chakra colorModeProvider."""

library = "/components/reflex/chakra_color_mode_provider.js"
library: str = "/components/reflex/chakra_color_mode_provider.js"
tag: str = "ChakraColorModeProvider"
is_default: bool = True

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/chakra/forms/iconbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IconButton(Text):
"""A button with an icon."""

tag: str = "IconButton"
library = "@chakra-ui/[email protected]"
library: str = "@chakra-ui/[email protected]"

# The type of button.
type: Optional[Var[str]] = None
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/chakra/forms/multiselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Select(Component):
Props added by chakra-react-select are marked with "[chakra]".
"""

library = "[email protected]"
library: str = "[email protected]"
tag: str = "Select"
alias = "MultiSelect"

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/chakra/media/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ChakraIconComponent(ChakraComponent):
"""A component that wraps a Chakra icon component."""

library = "@chakra-ui/[email protected]"
library: str = "@chakra-ui/[email protected]"


class Icon(ChakraIconComponent):
Expand Down
4 changes: 2 additions & 2 deletions reflex/components/core/client_side_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class ClientSideRouting(Component):
"""The client-side routing component."""

library = "/utils/client_side_routing"
library: str = "/utils/client_side_routing"
tag: str = "useClientSideRouting"

def _get_hooks(self) -> str:
Expand Down Expand Up @@ -61,7 +61,7 @@ def wait_for_client_redirect(component) -> Component:
class Default404Page(Component):
"""The NextJS default 404 page."""

library = "next/error"
library: str = "next/error"
tag: str = "Error"
is_default: bool = True

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/core/debounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DebounceInput(Component):
is experiencing high latency.
"""

library = "[email protected]"
library: str = "[email protected]"
tag: str = "DebounceInput"

# Minimum input characters before triggering the on_change event
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/core/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class UploadFilesProvider(Component):
class Upload(MemoizationLeaf):
"""A file upload component."""

library = "[email protected]"
library: str = "[email protected]"

tag: str = "ReactDropzone"

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/datadisplay/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
class CodeBlock(Component):
"""A code block."""

library = "[email protected]"
library: str = "[email protected]"

tag: str = "PrismAsyncLight"

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/gridjs/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Gridjs(Component):
"""A component that wraps a nivo bar component."""

library = "[email protected]"
library: str = "[email protected]"

lib_dependencies: List[str] = ["[email protected]"]

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/lucide/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class LucideIconComponent(Component):
"""Lucide Icon Component."""

library = "[email protected]"
library: str = "[email protected]"


class Icon(LucideIconComponent):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/markdown/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_base_component_map() -> dict[str, Callable]:
class Markdown(Component):
"""A markdown component."""

library = "[email protected]"
library: str = "[email protected]"

tag: str = "ReactMarkdown"

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/next/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Image(NextComponent):
"""Display an image."""

tag: str = "Image"
library = "next/image"
library: str = "next/image"
is_default: bool = True

# This can be either an absolute external URL, or an internal path
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/next/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class NextLink(Component):
"""Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink and semantically renders an <a>."""

library = "next/link"
library: str = "next/link"

tag: str = "NextLink"

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/next/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Video(NextComponent):
"""A video component from NextJS."""

tag: str = "Video"
library = "next-video"
library: str = "next-video"
is_default: bool = True
# the URL
src: Optional[Var[str]] = None
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class PlotlyLib(NoSSRComponent):
"""A component that wraps a plotly lib."""

library = "[email protected]"
library: str = "[email protected]"

lib_dependencies: List[str] = ["[email protected]"]

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/primitives/accordion.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def get_theme_accordion_content(variant: str | Var, color_scheme: str | Var) ->
class AccordionComponent(RadixPrimitiveComponent):
"""Base class for all @radix-ui/accordion components."""

library = "@radix-ui/react-accordion@^1.1.2"
library: str = "@radix-ui/react-accordion@^1.1.2"


class AccordionRoot(AccordionComponent):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/primitives/drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class DrawerComponent(RadixPrimitiveComponent):
"""A Drawer component."""

library = "vaul"
library: str = "vaul"

lib_dependencies: List[str] = ["@radix-ui/react-dialog@^1.0.5"]

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/primitives/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
class FormComponent(RadixPrimitiveComponentWithClassName):
"""Base class for all @radix-ui/react-form components."""

library = "@radix-ui/react-form@^0.0.3"
library: str = "@radix-ui/react-form@^0.0.3"


class FormRoot(FormComponent):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/primitives/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class ProgressComponent(RadixPrimitiveComponentWithClassName):
"""A Progress component."""

library = "@radix-ui/react-progress@^1.0.3"
library: str = "@radix-ui/react-progress@^1.0.3"


class ProgressRoot(ProgressComponent):
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/primitives/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class SliderComponent(RadixPrimitiveComponentWithClassName):
"""Base class for all @radix-ui/react-slider components."""

library = "@radix-ui/react-slider@^1.1.2"
library: str = "@radix-ui/react-slider@^1.1.2"


class SliderRoot(SliderComponent):
Expand Down
4 changes: 2 additions & 2 deletions reflex/components/radix/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CommonMarginProps(Component):
class RadixThemesComponent(Component):
"""Base class for all @radix-ui/themes components."""

library = "@radix-ui/themes@^2.0.0"
library: str = "@radix-ui/themes@^2.0.0"

# "Fake" prop color_scheme is used to avoid shadowing CSS prop "color".
_rename_props: Dict[str, str] = {"colorScheme": "color"}
Expand Down Expand Up @@ -216,7 +216,7 @@ class ThemePanel(RadixThemesComponent):
class RadixThemesColorModeProvider(Component):
"""Next-themes integration for radix themes components."""

library = "/components/reflex/radix_themes_color_mode_provider.js"
library: str = "/components/reflex/radix_themes_color_mode_provider.js"
tag: str = "RadixThemesColorModeProvider"
is_default: bool = True

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/react_player/react_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ReactPlayer(NoSSRComponent):
reference: https://github.com/cookpete/react-player.
"""

library = "[email protected]"
library: str = "[email protected]"

tag: str = "ReactPlayer"

Expand Down
4 changes: 2 additions & 2 deletions reflex/components/recharts/recharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
class Recharts(Component):
"""A component that wraps a recharts lib."""

library = "[email protected]"
library: str = "[email protected]"


class RechartsCharts(NoSSRComponent, MemoizationLeaf):
"""A component that wraps a recharts lib."""

library = "[email protected]"
library: str = "[email protected]"


LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/suneditor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Editor(NoSSRComponent):
refer to the library docs for a complete list.
"""

library = "suneditor-react"
library: str = "suneditor-react"

tag: str = "SunEditor"

Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def on_foo_spec(_e, alpha: str, bravo: Dict[str, Any], charlie: Obj):
return [_e.target.value, bravo["nested"], charlie.custom + 42]

class C1(Component):
library = "/local"
library: str = "/local"
tag: str = "C1"

def get_event_triggers(self) -> Dict[str, Any]:
Expand Down

0 comments on commit 16b7bae

Please sign in to comment.