Skip to content

Commit 319e4eb

Browse files
committed
pyi_generator: import from collections.abc instead of typing
Where possible, use new collections.abc imports instead of importing from typing. If the same-named typing imports are present, they will be removed.
1 parent 101fdb9 commit 319e4eb

File tree

2 files changed

+109
-111
lines changed

2 files changed

+109
-111
lines changed

packages/reflex-base/src/reflex_base/utils/pyi_generator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ def _safe_issubclass(cls: Any, cls_check: Any | tuple[Any, ...]) -> bool:
9696

9797
DEFAULT_TYPING_IMPORTS = {
9898
"Any",
99-
"Callable",
10099
"Dict",
101-
# "List",
102-
"Sequence",
103-
"Mapping",
104100
"Literal",
105101
"Optional",
106102
"Union",
@@ -109,6 +105,7 @@ def _safe_issubclass(cls: Any, cls_check: Any | tuple[Any, ...]) -> bool:
109105

110106
# TODO: fix import ordering and unused imports with ruff later
111107
DEFAULT_IMPORTS = {
108+
"collections.abc": ["Callable", "Mapping", "Sequence"],
112109
"typing": sorted(DEFAULT_TYPING_IMPORTS),
113110
"reflex_components_core.core.breakpoints": ["Breakpoints"],
114111
"reflex_base.event": [
@@ -124,6 +121,7 @@ def _safe_issubclass(cls: Any, cls_check: Any | tuple[Any, ...]) -> bool:
124121
}
125122
# These pre-0.9 imports might be present in the file and should be removed since the pyi generator will handle them separately.
126123
EXCLUDED_IMPORTS = {
124+
"typing": ["Callable", "Mapping", "Sequence"], # moved to collections.abc
127125
"reflex.components.core.breakpoints": ["Breakpoints"],
128126
"reflex.event": [
129127
"EventChain",

0 commit comments

Comments
 (0)