Skip to content

Commit 281410e

Browse files
committed
add better type hints to reactjs_component_from_*
1 parent 78bfa82 commit 281410e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

docs/source/about/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Unreleased
5757
- :pull:`1196` - Rewrite the ``event-to-object`` package to be more robust at handling properties on events.
5858

5959
**Deprecated**
60+
6061
-:pull:`1307` - ``reactpy.web.export`` is deprecated. Use ``reactpy.web.reactjs_component_from_*`` instead.
6162
-:pull:`1307` - ``reactpy.web.module_from_file`` is deprecated. Use ``reactpy.web.reactjs_component_from_file`` instead.
6263
-:pull:`1307` - ``reactpy.web.module_from_url`` is deprecated. Use ``reactpy.web.reactjs_component_from_url`` instead.

src/reactpy/web/module.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,30 @@
3333
_STRING_WEB_MODULE_CACHE: dict[str, WebModule] = {}
3434

3535

36+
@overload
37+
def reactjs_component_from_url(
38+
url: str,
39+
import_names: str,
40+
fallback: Any | None = ...,
41+
resolve_imports: bool | None = ...,
42+
resolve_imports_depth: int = ...,
43+
unmount_before_update: bool = ...,
44+
allow_children: bool = ...,
45+
) -> VdomConstructor: ...
46+
47+
48+
@overload
49+
def reactjs_component_from_url(
50+
url: str,
51+
import_names: list[str] | tuple[str, ...],
52+
fallback: Any | None = ...,
53+
resolve_imports: bool | None = ...,
54+
resolve_imports_depth: int = ...,
55+
unmount_before_update: bool = ...,
56+
allow_children: bool = ...,
57+
) -> list[VdomConstructor]: ...
58+
59+
3660
def reactjs_component_from_url(
3761
url: str,
3862
import_names: str | list[str] | tuple[str, ...],
@@ -80,6 +104,34 @@ def reactjs_component_from_url(
80104
return _vdom_from_web_module(module, import_names, fallback, allow_children)
81105

82106

107+
@overload
108+
def reactjs_component_from_file(
109+
name: str,
110+
file: str | Path,
111+
import_names: str,
112+
fallback: Any | None = ...,
113+
resolve_imports: bool | None = ...,
114+
resolve_imports_depth: int = ...,
115+
unmount_before_update: bool = ...,
116+
symlink: bool = ...,
117+
allow_children: bool = ...,
118+
) -> VdomConstructor: ...
119+
120+
121+
@overload
122+
def reactjs_component_from_file(
123+
name: str,
124+
file: str | Path,
125+
import_names: list[str] | tuple[str, ...],
126+
fallback: Any | None = ...,
127+
resolve_imports: bool | None = ...,
128+
resolve_imports_depth: int = ...,
129+
unmount_before_update: bool = ...,
130+
symlink: bool = ...,
131+
allow_children: bool = ...,
132+
) -> list[VdomConstructor]: ...
133+
134+
83135
def reactjs_component_from_file(
84136
name: str,
85137
file: str | Path,
@@ -135,6 +187,32 @@ def reactjs_component_from_file(
135187
return _vdom_from_web_module(module, import_names, fallback, allow_children)
136188

137189

190+
@overload
191+
def reactjs_component_from_string(
192+
name: str,
193+
content: str,
194+
import_names: str,
195+
fallback: Any | None = ...,
196+
resolve_imports: bool | None = ...,
197+
resolve_imports_depth: int = ...,
198+
unmount_before_update: bool = ...,
199+
allow_children: bool = ...,
200+
) -> VdomConstructor: ...
201+
202+
203+
@overload
204+
def reactjs_component_from_string(
205+
name: str,
206+
content: str,
207+
import_names: list[str] | tuple[str, ...],
208+
fallback: Any | None = ...,
209+
resolve_imports: bool | None = ...,
210+
resolve_imports_depth: int = ...,
211+
unmount_before_update: bool = ...,
212+
allow_children: bool = ...,
213+
) -> list[VdomConstructor]: ...
214+
215+
138216
def reactjs_component_from_string(
139217
name: str,
140218
content: str,

0 commit comments

Comments
 (0)