Skip to content

Commit 82bf4e5

Browse files
committed
give up on list
1 parent 7ee3438 commit 82bf4e5

4 files changed

Lines changed: 21 additions & 29 deletions

File tree

packages/reflex-components-radix/src/reflex_components_radix/themes/layout/list.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Iterable
5+
from collections.abc import Iterable, MutableSequence
66
from typing import Any, Literal
77

88
from reflex_components_core.core.foreach import Foreach
@@ -94,7 +94,7 @@ def add_style(self) -> dict[str, Any] | None:
9494
"direction": "column",
9595
}
9696

97-
def _exclude_props(self) -> list[str]:
97+
def _exclude_props(self) -> MutableSequence[str]:
9898
return ["items", "list_style_type"]
9999

100100

@@ -189,19 +189,7 @@ class List(ComponentNamespace):
189189
__call__ = staticmethod(BaseList.create)
190190

191191

192-
list_ns = List()
192+
list = list_ns = List()
193193
list_item = list_ns.item
194194
ordered_list = list_ns.ordered
195195
unordered_list = list_ns.unordered
196-
197-
198-
def __getattr__(name: Any):
199-
# special case for when accessing list to avoid shadowing
200-
# python's built in list object.
201-
if name == "list":
202-
return list_ns
203-
try:
204-
return globals()[name]
205-
except KeyError:
206-
msg = f"module '{__name__} has no attribute '{name}'"
207-
raise AttributeError(msg) from None

pyi_hashes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"packages/reflex-components-markdown/src/reflex_components_markdown/markdown.pyi": "bacf19a5b6904281d7238dbd51e6fc1c",
4444
"packages/reflex-components-moment/src/reflex_components_moment/moment.pyi": "b997bdd994844f0e6ca923bbb2dc34a1",
4545
"packages/reflex-components-plotly/src/reflex_components_plotly/plotly.pyi": "65a93d778a0fde06975dac9244f51bb3",
46-
"packages/reflex-components-radix/src/reflex_components_radix/__init__.pyi": "f54e0eac69cbca68ef94720ab439b52f",
46+
"packages/reflex-components-radix/src/reflex_components_radix/__init__.pyi": "7d5cd2fcd037c9b299c2c25b9a844db2",
4747
"packages/reflex-components-radix/src/reflex_components_radix/primitives/__init__.pyi": "289dfe0e5a59948b90b875ea8f75639c",
4848
"packages/reflex-components-radix/src/reflex_components_radix/primitives/accordion.pyi": "6dd30847af62ad7d50d5c5daf6c4a1d7",
4949
"packages/reflex-components-radix/src/reflex_components_radix/primitives/base.pyi": "6c12ef3d9f82926bf17d410b774d56f5",
@@ -91,14 +91,14 @@
9191
"packages/reflex-components-radix/src/reflex_components_radix/themes/components/text_area.pyi": "1a03d9525a1544816392067499c3354d",
9292
"packages/reflex-components-radix/src/reflex_components_radix/themes/components/text_field.pyi": "c2fbd8547de4993e03017844e8c4b477",
9393
"packages/reflex-components-radix/src/reflex_components_radix/themes/components/tooltip.pyi": "4545b70fd0802f19993419ab0163d595",
94-
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/__init__.pyi": "f7e4de67a6e656417246321cd992fd95",
94+
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/__init__.pyi": "49134dc875d5f3a8ef6215453ecd702b",
9595
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/base.pyi": "3195e198d92ff43644a09c277303b83b",
9696
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/box.pyi": "69d12b6c918a476ac4557f42fef73c27",
9797
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/center.pyi": "88880d197ff7347ec7d3f81d6e57de8e",
9898
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/container.pyi": "f329387a5d4a988bc195e6a487ff44db",
9999
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/flex.pyi": "855c9d0c3c2e79e7d3811cfec74d6379",
100100
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/grid.pyi": "bd2c31d4e3d61743b72327f071969e05",
101-
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/list.pyi": "856e0dd916fa69f152b3ec557871a133",
101+
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/list.pyi": "eee53b418ff0e0660c8cf9d8a0a59386",
102102
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/section.pyi": "1aa57142797597d65d840eb1d3cc7de7",
103103
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/spacer.pyi": "c774f0a1384f983e6d73bde603c341ca",
104104
"packages/reflex-components-radix/src/reflex_components_radix/themes/layout/stack.pyi": "894dcd5945123c1c8aa34cb77602fead",
@@ -118,7 +118,7 @@
118118
"packages/reflex-components-recharts/src/reflex_components_recharts/polar.pyi": "1ce679c002336c7bdbdd6c8ff6f2413c",
119119
"packages/reflex-components-recharts/src/reflex_components_recharts/recharts.pyi": "1b92135de4ea79cb7d94eaaec55b9ab7",
120120
"packages/reflex-components-sonner/src/reflex_components_sonner/toast.pyi": "f09c503c4ab880c13c13d6fa67d708b8",
121-
"reflex/__init__.pyi": "0d2fdfbd6860edc301afc744f198391a",
121+
"reflex/__init__.pyi": "7696c38fd9c04a598518b49c5185c414",
122122
"reflex/components/__init__.pyi": "55bb242d5e5428db329b88b4923c2ba5",
123123
"reflex/experimental/memo.pyi": "d16eccf33993c781e2f8bc2dd8bbd4d4"
124124
}

reflex/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
from reflex_components_radix.mappings import RADIX_MAPPING # noqa: E402
101101

102-
COMPONENTS_CORE_MAPPING: dict[str, list[str]] = {
102+
_COMPONENTS_CORE_MAPPING: dict[str, list[str]] = {
103103
"reflex_components_core.core.banner": [
104104
"connection_banner",
105105
"connection_modal",
@@ -131,12 +131,12 @@
131131
"reflex_components_core.core.window_events": ["window_event_listener"],
132132
}
133133

134-
COMPONENTS_BASE_MAPPING: dict[str, list[str]] = {
134+
_COMPONENTS_BASE_MAPPING: dict[str, list[str]] = {
135135
"reflex_components_core.base.fragment": ["fragment", "Fragment"],
136136
"reflex_components_core.base.script": ["script", "Script"],
137137
}
138138

139-
ALL_COMPONENTS_MAPPING: dict[str, list[str]] = {
139+
_ALL_COMPONENTS_MAPPING: dict[str, list[str]] = {
140140
"reflex_core.components.component": [
141141
"Component",
142142
"NoSSRComponent",
@@ -145,13 +145,13 @@
145145
],
146146
"reflex_components_core.el.elements.media": ["image"],
147147
"reflex_components_lucide": ["icon"],
148-
**COMPONENTS_BASE_MAPPING,
148+
**_COMPONENTS_BASE_MAPPING,
149149
"reflex_components_core": ["el"],
150150
"reflex_components_markdown.markdown": ["markdown"],
151151
**RADIX_MAPPING,
152152
"reflex_components_plotly": ["plotly"],
153153
"reflex_components_react_player": ["audio", "video"],
154-
**COMPONENTS_CORE_MAPPING,
154+
**_COMPONENTS_CORE_MAPPING,
155155
"reflex_components_code.code": [
156156
"code_block",
157157
],
@@ -166,9 +166,9 @@
166166
"reflex_components_moment": ["MomentDelta", "moment"],
167167
}
168168

169-
COMPONENT_NAME_TO_PATH: dict[str, str] = {
169+
_COMPONENT_NAME_TO_PATH: dict[str, str] = {
170170
comp: path + "." + comp
171-
for path, comps in ALL_COMPONENTS_MAPPING.items()
171+
for path, comps in _ALL_COMPONENTS_MAPPING.items()
172172
for comp in comps
173173
} | {
174174
"radix": "reflex_components_radix",
@@ -253,7 +253,7 @@
253253
"plugins",
254254
}
255255
_SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING
256-
_EXTRA_MAPPINGS: dict[str, str] = COMPONENT_NAME_TO_PATH
256+
_EXTRA_MAPPINGS: dict[str, str] = _COMPONENT_NAME_TO_PATH
257257
getattr, __dir__, __all__ = lazy_loader.attach(
258258
__name__,
259259
submodules=_SUBMODULES,

tests/units/components/test_component.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
from reflex_core.vars.object import ObjectVar
4343

4444
import reflex as rx
45+
from reflex import (
46+
_COMPONENTS_BASE_MAPPING, # pyright: ignore[reportAttributeAccessIssue]
47+
_COMPONENTS_CORE_MAPPING, # pyright: ignore[reportAttributeAccessIssue]
48+
)
4549
from reflex.compiler.utils import compile_custom_component
4650
from reflex.state import BaseState
4751
from reflex.utils import imports
@@ -1475,8 +1479,8 @@ def test_instantiate_all_components():
14751479
}
14761480
component_nested_list = [
14771481
*RADIX_MAPPING.values(),
1478-
*rx.COMPONENTS_BASE_MAPPING.values(),
1479-
*rx.COMPONENTS_CORE_MAPPING.values(),
1482+
*_COMPONENTS_BASE_MAPPING.values(),
1483+
*_COMPONENTS_CORE_MAPPING.values(),
14801484
]
14811485
for component_name in [
14821486
comp_name

0 commit comments

Comments
 (0)