Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-var-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-bartscher committed Sep 3, 2024
2 parents 1f6dfdb + 853d72e commit 3a7cbd6
Show file tree
Hide file tree
Showing 34 changed files with 717 additions and 1,044 deletions.
486 changes: 173 additions & 313 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ packages = [
[tool.poetry.dependencies]
python = "^3.8"
dill = ">=0.3.8,<0.4"
fastapi = ">=0.96.0,<0.111.0"
gunicorn = ">=20.1.0,<23.0"
fastapi = ">=0.96.0,!=0.111.0,!=0.111.1"
gunicorn = ">=20.1.0,<24.0"
jinja2 = ">=3.1.2,<4.0"
psutil = ">=5.9.4,<7.0"
pydantic = ">=1.10.2,<3.0"
Expand All @@ -40,8 +40,6 @@ rich = ">=13.0.0,<14.0"
sqlmodel = ">=0.0.14,<0.1"
typer = ">=0.4.2,<1.0"
uvicorn = ">=0.20.0"
watchdog = ">=2.3.1,<5.0"
watchfiles = ">=0.19.0,<1.0"
starlette-admin = ">=0.11.0,<1.0"
alembic = ">=1.11.1,<2.0"
platformdirs = ">=3.10.0,<5.0"
Expand Down
60 changes: 2 additions & 58 deletions reflex/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
)
from reflex.ivars.base import ImmutableVar, LiteralVar
from reflex.style import Style, format_as_emotion
from reflex.utils import console, format, imports, types
from reflex.utils import format, imports, types
from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports
from reflex.utils.serializers import serializer
from reflex.vars import BaseVar, ImmutableVarData, Var, VarData
Expand Down Expand Up @@ -527,15 +527,7 @@ def _create_event_chain(
for v in value:
if isinstance(v, (EventHandler, EventSpec)):
# Call the event handler to get the event.
try:
event = call_event_handler(v, args_spec)
except ValueError as err:
raise ValueError(
f" {err} defined in the `{type(self).__name__}` component"
) from err

# Add the event to the chain.
events.append(event)
events.append(call_event_handler(v, args_spec))
elif isinstance(v, Callable):
# Call the lambda to get the event chain.
result = call_event_fn(v, args_spec)
Expand Down Expand Up @@ -636,27 +628,6 @@ def __str__(self) -> str:

return _compile_component(self)

def _apply_theme(self, theme: Optional[Component]):
"""Apply the theme to this component.
Deprecated. Use add_style instead.
Args:
theme: The theme to apply.
"""
pass

def apply_theme(self, theme: Optional[Component]):
"""Apply a theme to the component and its children.
Args:
theme: The theme to apply.
"""
self._apply_theme(theme)
for child in self.children:
if isinstance(child, Component):
child.apply_theme(theme)

def _exclude_props(self) -> list[str]:
"""Props to exclude when adding the component props to the Tag.
Expand Down Expand Up @@ -764,22 +735,6 @@ def create(cls, *children, **props) -> Component:
from reflex.components.base.fragment import Fragment
from reflex.utils.exceptions import ComponentTypeError

# Translate deprecated props to new names.
new_prop_names = [
prop for prop in cls.get_props() if prop in ["type", "min", "max"]
]
for prop in new_prop_names:
under_prop = f"{prop}_"
if under_prop in props:
console.deprecate(
f"Underscore suffix for prop `{under_prop}`",
reason=f"for consistency. Use `{prop}` instead.",
deprecation_version="0.4.0",
removal_version="0.6.0",
dedupe=False,
)
props[prop] = props.pop(under_prop)

# Filter out None props
props = {key: value for key, value in props.items() if value is not None}

Expand Down Expand Up @@ -896,17 +851,6 @@ def _add_style_recursive(
new_style.update(component_style)
style_vars.append(component_style._var_data)

# 3. User-defined style from `Component.style`.
# Apply theme for retro-compatibility with deprecated _apply_theme API
if type(self)._apply_theme != Component._apply_theme:
console.deprecate(
f"{self.__class__.__name__}._apply_theme",
reason="use add_style instead",
deprecation_version="0.5.0",
removal_version="0.6.0",
)
self._apply_theme(theme)

# 4. style dict and css props passed to the component instance.
new_style.update(self.style)
style_vars.append(self.style._var_data)
Expand Down
10 changes: 0 additions & 10 deletions reflex/components/core/foreach.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from reflex.constants import MemoizationMode
from reflex.ivars.base import ImmutableVar
from reflex.state import ComponentState
from reflex.utils import console
from reflex.vars import Var


Expand Down Expand Up @@ -39,14 +38,12 @@ def create(
cls,
iterable: Var[Iterable] | Iterable,
render_fn: Callable,
**props,
) -> Foreach:
"""Create a foreach component.
Args:
iterable: The iterable to create components from.
render_fn: A function from the render args to the component.
**props: The attributes to pass to each child component (deprecated).
Returns:
The foreach component.
Expand All @@ -55,13 +52,6 @@ def create(
ForeachVarError: If the iterable is of type Any.
TypeError: If the render function is a ComponentState.
"""
if props:
console.deprecate(
feature_name="Passing props to rx.foreach",
reason="it does not have the intended effect and may be confusing",
deprecation_version="0.5.0",
removal_version="0.6.0",
)
iterable = ImmutableVar.create_safe(iterable)
if iterable._var_type == Any:
raise ForeachVarError(
Expand Down
1 change: 0 additions & 1 deletion reflex/components/el/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
_SUBMOD_ATTRS: dict[str, list[str]] = {
f"elements.{k}": v for k, v in elements._MAPPING.items()
}
_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS

__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
Expand Down
11 changes: 0 additions & 11 deletions reflex/components/el/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------

from . import elements
from .elements.forms import Button as Button
from .elements.forms import Fieldset as Fieldset
from .elements.forms import Form as Form
Expand Down Expand Up @@ -88,36 +87,28 @@ from .elements.inline import u as u
from .elements.inline import wbr as wbr
from .elements.media import Area as Area
from .elements.media import Audio as Audio
from .elements.media import Defs as Defs
from .elements.media import Embed as Embed
from .elements.media import Iframe as Iframe
from .elements.media import Img as Img
from .elements.media import LinearGradient as LinearGradient
from .elements.media import Map as Map
from .elements.media import Object as Object
from .elements.media import Path as Path
from .elements.media import Picture as Picture
from .elements.media import Portal as Portal
from .elements.media import Source as Source
from .elements.media import Stop as Stop
from .elements.media import Svg as Svg
from .elements.media import Track as Track
from .elements.media import Video as Video
from .elements.media import area as area
from .elements.media import audio as audio
from .elements.media import defs as defs # type: ignore
from .elements.media import embed as embed
from .elements.media import iframe as iframe
from .elements.media import image as image
from .elements.media import img as img
from .elements.media import lineargradient as lineargradient # type: ignore
from .elements.media import map as map
from .elements.media import object as object
from .elements.media import path as path # type: ignore
from .elements.media import picture as picture
from .elements.media import portal as portal
from .elements.media import source as source
from .elements.media import stop as stop # type: ignore
from .elements.media import svg as svg
from .elements.media import track as track
from .elements.media import video as video
Expand Down Expand Up @@ -231,5 +222,3 @@ from .elements.typography import ol as ol
from .elements.typography import p as p
from .elements.typography import pre as pre
from .elements.typography import ul as ul

_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS
8 changes: 1 addition & 7 deletions reflex/components/el/elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
"portal",
"source",
"svg",
"defs",
"lineargradient",
"LinearGradient",
"stop",
"path",
],
"metadata": [
"base",
Expand Down Expand Up @@ -130,13 +125,12 @@
}


EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
EXCLUDE = ["del_", "Del", "image"]
for _, v in _MAPPING.items():
v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])

_SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING

_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
submod_attrs=_SUBMOD_ATTRS,
Expand Down
16 changes: 1 addition & 15 deletions reflex/components/el/elements/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,28 @@ from .inline import u as u
from .inline import wbr as wbr
from .media import Area as Area
from .media import Audio as Audio
from .media import Defs as Defs
from .media import Embed as Embed
from .media import Iframe as Iframe
from .media import Img as Img
from .media import LinearGradient as LinearGradient
from .media import Map as Map
from .media import Object as Object
from .media import Path as Path
from .media import Picture as Picture
from .media import Portal as Portal
from .media import Source as Source
from .media import Stop as Stop
from .media import Svg as Svg
from .media import Track as Track
from .media import Video as Video
from .media import area as area
from .media import audio as audio
from .media import defs as defs # type: ignore
from .media import embed as embed
from .media import iframe as iframe
from .media import image as image
from .media import img as img
from .media import lineargradient as lineargradient # type: ignore
from .media import map as map
from .media import object as object
from .media import path as path # type: ignore
from .media import picture as picture
from .media import portal as portal
from .media import source as source
from .media import stop as stop # type: ignore
from .media import svg as svg
from .media import track as track
from .media import video as video
Expand Down Expand Up @@ -292,11 +284,6 @@ _MAPPING = {
"portal",
"source",
"svg",
"defs",
"lineargradient",
"LinearGradient",
"stop",
"path",
],
"metadata": ["base", "head", "link", "meta", "title", "style"],
"other": ["details", "dialog", "summary", "slot", "template", "math", "html"],
Expand Down Expand Up @@ -348,7 +335,6 @@ _MAPPING = {
"Del",
],
}
EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
EXCLUDE = ["del_", "Del", "image"]
for _, v in _MAPPING.items():
v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
21 changes: 0 additions & 21 deletions reflex/components/el/elements/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from reflex import Component, ComponentNamespace
from reflex.constants.colors import Color
from reflex.utils import console
from reflex.vars import Var as Var

from .base import BaseHTML
Expand Down Expand Up @@ -445,23 +444,3 @@ class SVG(ComponentNamespace):
portal = Portal.create
source = Source.create
svg = SVG()


def __getattr__(name: str):
if name in ("defs", "lineargradient", "stop", "path"):
console.deprecate(
f"`rx.el.{name}`",
reason=f"use `rx.el.svg.{'linear_gradient' if name =='lineargradient' else name}`",
deprecation_version="0.5.8",
removal_version="0.6.0",
)
return (
LinearGradient.create
if name == "lineargradient"
else globals()[name.capitalize()].create
)

try:
return globals()[name]
except KeyError:
raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None
Loading

0 comments on commit 3a7cbd6

Please sign in to comment.