From 8e7d4819ee9fe2e86c3c2eb40a37c2ac9d43dca4 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 17 Nov 2023 15:21:52 -0800 Subject: [PATCH] check_generated_pyi: fix diff checking (#2029) --- .github/workflows/check_generated_pyi.yml | 11 +++++--- .gitignore | 1 + reflex/components/forms/iconbutton.pyi | 2 ++ reflex/components/forms/radio.pyi | 2 ++ reflex/components/forms/select.pyi | 2 ++ .../components/graphing/recharts/cartesian.py | 14 +++++----- reflex/components/graphing/recharts/charts.py | 18 ++++++------- .../components/graphing/recharts/general.py | 2 +- reflex/components/graphing/recharts/polar.py | 12 ++++----- reflex/components/overlay/modal.pyi | 27 +++++-------------- reflex/components/typography/text.pyi | 2 ++ scripts/pyi_generator.py | 4 +-- 12 files changed, 48 insertions(+), 49 deletions(-) diff --git a/.github/workflows/check_generated_pyi.yml b/.github/workflows/check_generated_pyi.yml index 39b988c5b..0d283c8b0 100644 --- a/.github/workflows/check_generated_pyi.yml +++ b/.github/workflows/check_generated_pyi.yml @@ -26,8 +26,11 @@ jobs: create-venv-at-path: .venv - run: | poetry run python scripts/pyi_generator.py - if git diff; then - echo "No diffs - AOK!" - else + if [[ $(git status --porcelain) ]]; then + git status + git diff echo "ERROR: pyi_generator.py output is out of date. Please run scripts/pyi_generator.py and commit the changes." - fi \ No newline at end of file + exit 1 + else + echo "No diffs - AOK!" + fi diff --git a/.gitignore b/.gitignore index df43a9c49..0e93a4a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ examples/ .vscode .coverage .coverage.* +.venv venv diff --git a/reflex/components/forms/iconbutton.pyi b/reflex/components/forms/iconbutton.pyi index 168d6f9a9..4e452b6f5 100644 --- a/reflex/components/forms/iconbutton.pyi +++ b/reflex/components/forms/iconbutton.pyi @@ -27,6 +27,7 @@ class IconButton(Text): is_round: Optional[Union[Var[bool], bool]] = None, spinner: Optional[Union[Var[str], str]] = None, as_: Optional[Union[Var[str], str]] = None, + no_of_lines: Optional[Union[Var[int], int]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -93,6 +94,7 @@ class IconButton(Text): is_round: If true, the button will be perfectly round. Else, it'll be slightly round spinner: Replace the spinner component when isLoading is set to true as_: Override the tag. The default tag is `

`. + no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/forms/radio.pyi b/reflex/components/forms/radio.pyi index 0930f9552..dd6e57ac2 100644 --- a/reflex/components/forms/radio.pyi +++ b/reflex/components/forms/radio.pyi @@ -118,6 +118,7 @@ class Radio(Text): is_read_only: Optional[Union[Var[bool], bool]] = None, is_required: Optional[Union[Var[bool], bool]] = None, as_: Optional[Union[Var[str], str]] = None, + no_of_lines: Optional[Union[Var[int], int]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -187,6 +188,7 @@ class Radio(Text): is_read_only: If true, the radio will be read-only is_required: If true, the radio button will be required. This also sets `aria-required` to true. as_: Override the tag. The default tag is `

`. + no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/forms/select.pyi b/reflex/components/forms/select.pyi index 42a6b1f6a..5596e6a7a 100644 --- a/reflex/components/forms/select.pyi +++ b/reflex/components/forms/select.pyi @@ -134,6 +134,7 @@ class Option(Text): *children, value: Optional[Union[Var[Any], Any]] = None, as_: Optional[Union[Var[str], str]] = None, + no_of_lines: Optional[Union[Var[int], int]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -194,6 +195,7 @@ class Option(Text): Args: *children: The children of the component. as_: Override the tag. The default tag is `

`. + no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/graphing/recharts/cartesian.py b/reflex/components/graphing/recharts/cartesian.py index 24fd4bb08..136bddf9f 100644 --- a/reflex/components/graphing/recharts/cartesian.py +++ b/reflex/components/graphing/recharts/cartesian.py @@ -278,7 +278,7 @@ class Bar(Cartesian): max_bar_size: Var[int] # Valid children components - valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"] + _valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"] class Line(Cartesian): @@ -313,7 +313,7 @@ class Line(Cartesian): connect_nulls: Var[bool] # Valid children components - valid_children: List[str] = ["LabelList", "ErrorBar"] + _valid_children: List[str] = ["LabelList", "ErrorBar"] class Scatter(Cartesian): @@ -345,7 +345,7 @@ class Scatter(Cartesian): name: Var[Union[str, int]] # Valid children components. - valid_children: List[str] = ["LabelList", "ErrorBar"] + _valid_children: List[str] = ["LabelList", "ErrorBar"] class Funnel(Cartesian): @@ -368,7 +368,7 @@ class Funnel(Cartesian): animation_easing: Var[LiteralAnimationEasing] # Valid children components - valid_children: List[str] = ["LabelList", "Cell"] + _valid_children: List[str] = ["LabelList", "Cell"] class ErrorBar(Recharts): @@ -427,7 +427,7 @@ class ReferenceLine(Reference): stroke_width: Var[int] # Valid children components - valid_children: List[str] = ["Label"] + _valid_children: List[str] = ["Label"] class ReferenceDot(Reference): @@ -438,7 +438,7 @@ class ReferenceDot(Reference): alias = "RechartsReferenceDot" # Valid children components - valid_children: List[str] = ["Label"] + _valid_children: List[str] = ["Label"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -497,7 +497,7 @@ class ReferenceArea(Recharts): is_front: Var[bool] # Valid children components - valid_children: List[str] = ["Label"] + _valid_children: List[str] = ["Label"] class Grid(Recharts): diff --git a/reflex/components/graphing/recharts/charts.py b/reflex/components/graphing/recharts/charts.py index bc598b5c6..b0150cc34 100644 --- a/reflex/components/graphing/recharts/charts.py +++ b/reflex/components/graphing/recharts/charts.py @@ -130,7 +130,7 @@ class AreaChart(ChartBase): stack_offset: Var[LiteralStackOffset] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -170,7 +170,7 @@ class BarChart(ChartBase): reverse_stack_order: Var[bool] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -192,7 +192,7 @@ class LineChart(ChartBase): alias = "RechartsLineChart" # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -229,7 +229,7 @@ class ComposedChart(ChartBase): reverse_stack_order: Var[bool] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -253,7 +253,7 @@ class PieChart(ChartBase): alias = "RechartsPieChart" # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -301,7 +301,7 @@ class RadarChart(ChartBase): outer_radius: Var[Union[int, str]] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -359,7 +359,7 @@ class RadialBarChart(ChartBase): bar_size: Var[int] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -390,7 +390,7 @@ class ScatterChart(ChartBase): alias = "RechartsScatterChart" # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "XAxis", "YAxis", "ZAxis", @@ -455,7 +455,7 @@ class FunnelChart(RechartsCharts): layout: Var[str] # Valid children components - valid_children: List[str] = ["Legend", "GraphingTooltip", "Funnel"] + _valid_children: List[str] = ["Legend", "GraphingTooltip", "Funnel"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. diff --git a/reflex/components/graphing/recharts/general.py b/reflex/components/graphing/recharts/general.py index 868187d6f..7a36850c8 100644 --- a/reflex/components/graphing/recharts/general.py +++ b/reflex/components/graphing/recharts/general.py @@ -42,7 +42,7 @@ class ResponsiveContainer(Recharts): debounce: Var[int] # Valid children components - valid_children: List[str] = [ + _valid_children: List[str] = [ "AreaChart", "BarChart", "LineChart", diff --git a/reflex/components/graphing/recharts/polar.py b/reflex/components/graphing/recharts/polar.py index 44817a763..256695740 100644 --- a/reflex/components/graphing/recharts/polar.py +++ b/reflex/components/graphing/recharts/polar.py @@ -65,7 +65,7 @@ class Pie(Recharts): label_line: Var[bool] # Valid children components - valid_children: List[str] = ["Cell", "LabelList"] + _valid_children: List[str] = ["Cell", "LabelList"] # fill color fill: Var[str] @@ -130,7 +130,7 @@ class Radar(Recharts): animation_easing: Var[LiteralAnimationEasing] # Valid children components - valid_children: List[str] = ["LabelList"] + _valid_children: List[str] = ["LabelList"] class RadialBar(Recharts): @@ -156,7 +156,7 @@ class RadialBar(Recharts): background: Var[bool] # Valid children components - valid_children: List[str] = ["LabelList"] + _valid_children: List[str] = ["LabelList"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -215,7 +215,7 @@ class PolarAngleAxis(Recharts): allow_duplicated_category: Var[bool] # Valid children components - valid_children: List[str] = ["Label"] + _valid_children: List[str] = ["Label"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -262,7 +262,7 @@ class PolarGrid(Recharts): grid_type: Var[LiteralGridType] # Valid children components - valid_children: List[str] = ["RadarChart", "RadiarBarChart"] + _valid_children: List[str] = ["RadarChart", "RadiarBarChart"] class PolarRadiusAxis(Recharts): @@ -306,7 +306,7 @@ class PolarRadiusAxis(Recharts): scale: Var[LiteralScale] # Valid children components - valid_children: List[str] = ["Label"] + _valid_children: List[str] = ["Label"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. diff --git a/reflex/components/overlay/modal.pyi b/reflex/components/overlay/modal.pyi index 8d9f8fc15..22f3fcde9 100644 --- a/reflex/components/overlay/modal.pyi +++ b/reflex/components/overlay/modal.pyi @@ -7,12 +7,14 @@ from typing import Any, Dict, Literal, Optional, Union, overload from reflex.vars import Var, BaseVar, ComputedVar from reflex.event import EventChain, EventHandler, EventSpec from reflex.style import Style -from typing import Any, Optional, Union +from typing import Any, Literal, Optional, Union from reflex.components.component import Component -from reflex.components.libs.chakra import ChakraComponent, LiteralAlertDialogSize +from reflex.components.libs.chakra import ChakraComponent from reflex.components.media import Icon from reflex.vars import Var +ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"] + class Modal(ChakraComponent): def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @@ -37,23 +39,8 @@ class Modal(ChakraComponent): return_focus_on_close: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ - Var[ - Literal[ - "sm", - "md", - "lg", - "xs", - "2xl", - "full", - "3xl", - "4xl", - "5xl", - "6xl", - ] - ], - Literal[ - "sm", "md", "lg", "xs", "2xl", "full", "3xl", "4xl", "5xl", "6xl" - ], + Var[Literal["xs", "sm", "md", "lg", "xl", "full"]], + Literal["xs", "sm", "md", "lg", "xl", "full"], ] ] = None, use_inert: Optional[Union[Var[bool], bool]] = None, @@ -141,7 +128,7 @@ class Modal(ChakraComponent): motion_preset: The transition that should be used for the modal preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes. - size: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full" + size: "xs" | "sm" | "md" | "lg" | "xl" | "full" use_inert: A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** style: The style of the component. key: A unique key for the component. diff --git a/reflex/components/typography/text.pyi b/reflex/components/typography/text.pyi index 22a9e8d3e..ecfb2c1c0 100644 --- a/reflex/components/typography/text.pyi +++ b/reflex/components/typography/text.pyi @@ -17,6 +17,7 @@ class Text(ChakraComponent): cls, *children, as_: Optional[Union[Var[str], str]] = None, + no_of_lines: Optional[Union[Var[int], int]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -75,6 +76,7 @@ class Text(ChakraComponent): Args: *children: The children of the component. as_: Override the tag. The default tag is `

`. + no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/scripts/pyi_generator.py b/scripts/pyi_generator.py index 9f531a1b7..37a98988f 100644 --- a/scripts/pyi_generator.py +++ b/scripts/pyi_generator.py @@ -38,13 +38,13 @@ EXCLUDED_PROPS = [ "alias", "children", "event_triggers", - "invalid_children", "library", "lib_dependencies", "tag", "is_default", "special_props", - "valid_children", + "_invalid_children", + "_valid_children", ] DEFAULT_TYPING_IMPORTS = {