Skip to content

Commit 9ce3a96

Browse files
committed
reorganize args on reactjs_component_from_*
1 parent 7d86175 commit 9ce3a96

File tree

1 file changed

+44
-51
lines changed

1 file changed

+44
-51
lines changed

src/reactpy/web/module.py

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
def reactjs_component_from_url(
3939
url: str,
4040
import_names: str,
41-
fallback: Any | None = ...,
42-
resolve_imports: bool | None = ...,
41+
resolve_imports: bool = ...,
4342
resolve_imports_depth: int = ...,
43+
fallback: Any | None = ...,
4444
unmount_before_update: bool = ...,
4545
allow_children: bool = ...,
4646
) -> VdomConstructor: ...
@@ -50,9 +50,9 @@ def reactjs_component_from_url(
5050
def reactjs_component_from_url(
5151
url: str,
5252
import_names: list[str] | tuple[str, ...],
53-
fallback: Any | None = ...,
54-
resolve_imports: bool | None = ...,
53+
resolve_imports: bool = ...,
5554
resolve_imports_depth: int = ...,
55+
fallback: Any | None = ...,
5656
unmount_before_update: bool = ...,
5757
allow_children: bool = ...,
5858
) -> list[VdomConstructor]: ...
@@ -61,9 +61,9 @@ def reactjs_component_from_url(
6161
def reactjs_component_from_url(
6262
url: str,
6363
import_names: str | list[str] | tuple[str, ...],
64-
fallback: Any | None = None,
65-
resolve_imports: bool | None = None,
64+
resolve_imports: bool = True,
6665
resolve_imports_depth: int = 5,
66+
fallback: Any | None = None,
6767
unmount_before_update: bool = False,
6868
allow_children: bool = True,
6969
) -> VdomConstructor | list[VdomConstructor]:
@@ -76,12 +76,12 @@ def reactjs_component_from_url(
7676
One or more component names to import. If given as a string, a single component
7777
will be returned. If a list is given, then a list of components will be
7878
returned.
79-
fallback:
80-
What to temporarily display while the module is being loaded.
8179
resolve_imports:
8280
Whether to try and find all the named imports of this module.
8381
resolve_imports_depth:
8482
How deeply to search for those imports.
83+
fallback:
84+
What to temporarily display while the module is being loaded.
8585
unmount_before_update:
8686
Cause the component to be unmounted before each update. This option should
8787
only be used if the imported package fails to re-render when props change.
@@ -109,12 +109,11 @@ def reactjs_component_from_url(
109109
def reactjs_component_from_npm(
110110
package: str,
111111
import_names: str,
112+
resolve_imports: bool = ...,
113+
resolve_imports_depth: int = ...,
112114
version: str = "latest",
113-
file: str = "",
114115
cdn: str = "https://esm.sh",
115116
fallback: Any | None = ...,
116-
resolve_imports: bool | None = ...,
117-
resolve_imports_depth: int = ...,
118117
unmount_before_update: bool = ...,
119118
allow_children: bool = ...,
120119
) -> VdomConstructor: ...
@@ -124,12 +123,11 @@ def reactjs_component_from_npm(
124123
def reactjs_component_from_npm(
125124
package: str,
126125
import_names: list[str] | tuple[str, ...],
126+
resolve_imports: bool = ...,
127+
resolve_imports_depth: int = ...,
127128
version: str = "latest",
128-
file: str = "",
129129
cdn: str = "https://esm.sh",
130130
fallback: Any | None = ...,
131-
resolve_imports: bool | None = ...,
132-
resolve_imports_depth: int = ...,
133131
unmount_before_update: bool = ...,
134132
allow_children: bool = ...,
135133
) -> list[VdomConstructor]: ...
@@ -138,12 +136,11 @@ def reactjs_component_from_npm(
138136
def reactjs_component_from_npm(
139137
package: str,
140138
import_names: str | list[str] | tuple[str, ...],
139+
resolve_imports: bool = True,
140+
resolve_imports_depth: int = 5,
141141
version: str = "latest",
142-
file: str = "",
143142
cdn: str = "https://esm.sh",
144143
fallback: Any | None = None,
145-
resolve_imports: bool | None = None,
146-
resolve_imports_depth: int = 5,
147144
unmount_before_update: bool = False,
148145
allow_children: bool = True,
149146
) -> VdomConstructor | list[VdomConstructor]:
@@ -156,18 +153,16 @@ def reactjs_component_from_npm(
156153
One or more component names to import. If given as a string, a single component
157154
will be returned. If a list is given, then a list of components will be
158155
returned.
156+
resolve_imports:
157+
Whether to try and find all the named imports of this module.
158+
resolve_imports_depth:
159+
How deeply to search for those imports.
159160
version:
160161
The version of the package to use. Defaults to "latest".
161-
file:
162-
A specific file to import from the package.
163162
cdn:
164163
The CDN to use. Defaults to "https://esm.sh".
165164
fallback:
166165
What to temporarily display while the module is being loaded.
167-
resolve_imports:
168-
Whether to try and find all the named imports of this module.
169-
resolve_imports_depth:
170-
How deeply to search for those imports.
171166
unmount_before_update:
172167
Cause the component to be unmounted before each update. This option should
173168
only be used if the imported package fails to re-render when props change.
@@ -177,8 +172,6 @@ def reactjs_component_from_npm(
177172
Whether or not these components can have children.
178173
"""
179174
url = f"{cdn}/{package}@{version}"
180-
if file:
181-
url += f"/{file}"
182175

183176
if "esm.sh" in cdn:
184177
if "?" in url:
@@ -201,10 +194,10 @@ def reactjs_component_from_npm(
201194
def reactjs_component_from_file(
202195
file: str | Path,
203196
import_names: str,
197+
resolve_imports: bool = ...,
198+
resolve_imports_depth: int = ...,
204199
name: str = "",
205200
fallback: Any | None = ...,
206-
resolve_imports: bool | None = ...,
207-
resolve_imports_depth: int = ...,
208201
unmount_before_update: bool = ...,
209202
symlink: bool = ...,
210203
allow_children: bool = ...,
@@ -215,10 +208,10 @@ def reactjs_component_from_file(
215208
def reactjs_component_from_file(
216209
file: str | Path,
217210
import_names: list[str] | tuple[str, ...],
211+
resolve_imports: bool = ...,
212+
resolve_imports_depth: int = ...,
218213
name: str = "",
219214
fallback: Any | None = ...,
220-
resolve_imports: bool | None = ...,
221-
resolve_imports_depth: int = ...,
222215
unmount_before_update: bool = ...,
223216
symlink: bool = ...,
224217
allow_children: bool = ...,
@@ -228,10 +221,10 @@ def reactjs_component_from_file(
228221
def reactjs_component_from_file(
229222
file: str | Path,
230223
import_names: str | list[str] | tuple[str, ...],
224+
resolve_imports: bool = True,
225+
resolve_imports_depth: int = 5,
231226
name: str = "",
232227
fallback: Any | None = None,
233-
resolve_imports: bool | None = None,
234-
resolve_imports_depth: int = 5,
235228
unmount_before_update: bool = False,
236229
symlink: bool = False,
237230
allow_children: bool = True,
@@ -245,14 +238,14 @@ def reactjs_component_from_file(
245238
One or more component names to import. If given as a string, a single component
246239
will be returned. If a list is given, then a list of components will be
247240
returned.
248-
name:
249-
The human-readable name of the ReactJS package
250-
fallback:
251-
What to temporarily display while the module is being loaded.
252241
resolve_imports:
253242
Whether to try and find all the named imports of this module.
254243
resolve_imports_depth:
255244
How deeply to search for those imports.
245+
name:
246+
The human-readable name of the ReactJS package
247+
fallback:
248+
What to temporarily display while the module is being loaded.
256249
unmount_before_update:
257250
Cause the component to be unmounted before each update. This option should
258251
only be used if the imported package fails to re-render when props change.
@@ -285,10 +278,10 @@ def reactjs_component_from_file(
285278
def reactjs_component_from_string(
286279
content: str,
287280
import_names: str,
281+
resolve_imports: bool = ...,
282+
resolve_imports_depth: int = ...,
288283
name: str = "",
289284
fallback: Any | None = ...,
290-
resolve_imports: bool | None = ...,
291-
resolve_imports_depth: int = ...,
292285
unmount_before_update: bool = ...,
293286
allow_children: bool = ...,
294287
) -> VdomConstructor: ...
@@ -298,10 +291,10 @@ def reactjs_component_from_string(
298291
def reactjs_component_from_string(
299292
content: str,
300293
import_names: list[str] | tuple[str, ...],
294+
resolve_imports: bool = ...,
295+
resolve_imports_depth: int = ...,
301296
name: str = "",
302297
fallback: Any | None = ...,
303-
resolve_imports: bool | None = ...,
304-
resolve_imports_depth: int = ...,
305298
unmount_before_update: bool = ...,
306299
allow_children: bool = ...,
307300
) -> list[VdomConstructor]: ...
@@ -310,10 +303,10 @@ def reactjs_component_from_string(
310303
def reactjs_component_from_string(
311304
content: str,
312305
import_names: str | list[str] | tuple[str, ...],
306+
resolve_imports: bool = True,
307+
resolve_imports_depth: int = 5,
313308
name: str = "",
314309
fallback: Any | None = None,
315-
resolve_imports: bool | None = None,
316-
resolve_imports_depth: int = 5,
317310
unmount_before_update: bool = False,
318311
allow_children: bool = True,
319312
) -> VdomConstructor | list[VdomConstructor]:
@@ -326,14 +319,14 @@ def reactjs_component_from_string(
326319
One or more component names to import. If given as a string, a single component
327320
will be returned. If a list is given, then a list of components will be
328321
returned.
329-
name:
330-
The human-readable name of the ReactJS package
331-
fallback:
332-
What to temporarily display while the module is being loaded.
333322
resolve_imports:
334323
Whether to try and find all the named imports of this module.
335324
resolve_imports_depth:
336325
How deeply to search for those imports.
326+
name:
327+
The human-readable name of the ReactJS package
328+
fallback:
329+
What to temporarily display while the module is being loaded.
337330
unmount_before_update:
338331
Cause the component to be unmounted before each update. This option should
339332
only be used if the imported package fails to re-render when props change.
@@ -362,7 +355,7 @@ def reactjs_component_from_string(
362355
def module_from_url(
363356
url: str,
364357
fallback: Any | None = None,
365-
resolve_exports: bool | None = None,
358+
resolve_exports: bool = False,
366359
resolve_exports_depth: int = 5,
367360
unmount_before_update: bool = False,
368361
) -> WebModule: # pragma: no cover
@@ -383,7 +376,7 @@ def module_from_file(
383376
name: str,
384377
file: str | Path,
385378
fallback: Any | None = None,
386-
resolve_exports: bool | None = None,
379+
resolve_exports: bool = False,
387380
resolve_exports_depth: int = 5,
388381
unmount_before_update: bool = False,
389382
symlink: bool = False,
@@ -407,7 +400,7 @@ def module_from_string(
407400
name: str,
408401
content: str,
409402
fallback: Any | None = None,
410-
resolve_exports: bool | None = None,
403+
resolve_exports: bool = False,
411404
resolve_exports_depth: int = 5,
412405
unmount_before_update: bool = False,
413406
) -> WebModule: # pragma: no cover
@@ -428,7 +421,7 @@ def module_from_string(
428421
def _module_from_url(
429422
url: str,
430423
fallback: Any | None = None,
431-
resolve_imports: bool | None = None,
424+
resolve_imports: bool = True,
432425
resolve_imports_depth: int = 5,
433426
unmount_before_update: bool = False,
434427
) -> WebModule:
@@ -454,7 +447,7 @@ def _module_from_file(
454447
name: str,
455448
file: str | Path,
456449
fallback: Any | None = None,
457-
resolve_imports: bool | None = None,
450+
resolve_imports: bool = True,
458451
resolve_imports_depth: int = 5,
459452
unmount_before_update: bool = False,
460453
symlink: bool = False,
@@ -515,7 +508,7 @@ def _module_from_string(
515508
name: str,
516509
content: str,
517510
fallback: Any | None = None,
518-
resolve_imports: bool | None = None,
511+
resolve_imports: bool = True,
519512
resolve_imports_depth: int = 5,
520513
unmount_before_update: bool = False,
521514
) -> WebModule:

0 commit comments

Comments
 (0)