Skip to content

Commit ffdb041

Browse files
committed
More formatting fixes
1 parent 7923573 commit ffdb041

File tree

6 files changed

+96
-93
lines changed

6 files changed

+96
-93
lines changed

src/js/packages/@reactpy/client/src/vdom.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,22 @@ function createImportSourceElement(props: {
105105
);
106106
}
107107

108-
function tryGetSubType(
109-
module: ReactPyModule,
110-
component: string
111-
) {
108+
function tryGetSubType(module: ReactPyModule, component: string) {
112109
let subComponents: string[] = component.split(".");
113110
let rootComponent: string = subComponents[0];
114111
let subComponentAccessor: string = rootComponent;
115112
let type: any = module[rootComponent];
116-
113+
117114
subComponents = subComponents.slice(1);
118115
for (let i = 0; i < subComponents.length; i++) {
119116
let subComponent = subComponents[i];
120117
subComponentAccessor += "." + subComponent;
121118
type = type[subComponent];
122119
if (!type) {
123120
console.error(
124-
`Component ${rootComponent} does not have subcomponent ${subComponentAccessor}`
121+
`Component ${rootComponent} does not have subcomponent ${subComponentAccessor}`,
125122
);
126-
break
123+
break;
127124
}
128125
}
129126
return type;

src/reactpy/core/vdom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __getattr__(self, attr: str) -> Vdom:
139139
return Vdom(
140140
f"{self.__name__}.{attr}",
141141
allow_children=self.allow_children,
142-
import_source=self.import_source
142+
import_source=self.import_source,
143143
)
144144

145145
@overload

src/reactpy/web/module.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@ def export(
267267
return _make_export(web_module, export_names, fallback, allow_children)
268268
else:
269269
if web_module.export_names is not None:
270-
missing = sorted({e.split(".")[0] for e in export_names}.difference(web_module.export_names))
270+
missing = sorted(
271+
{e.split(".")[0] for e in export_names}.difference(
272+
web_module.export_names
273+
)
274+
)
271275
if missing:
272276
msg = f"{web_module.source!r} does not export {missing!r}"
273277
raise ValueError(msg)

tests/test_core/test_vdom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def test_is_vdom(result, value):
7171
{"tagName": "div", "attributes": {"tagName": "div"}},
7272
),
7373
(
74-
reactpy.Vdom("div")((i for i in range(3))),
74+
reactpy.Vdom("div")(i for i in range(3)),
7575
{"tagName": "div", "children": [0, 1, 2]},
7676
),
7777
(
78-
reactpy.Vdom("div")((x**2 for x in [1, 2, 3])),
78+
reactpy.Vdom("div")(x**2 for x in [1, 2, 3]),
7979
{"tagName": "div", "children": [1, 4, 9]},
8080
),
8181
(
@@ -293,7 +293,7 @@ def test_invalid_vdom(value, error_message_pattern):
293293
@pytest.mark.skipif(not REACTPY_DEBUG.current, reason="Only warns in debug mode")
294294
def test_warn_cannot_verify_keypath_for_genereators():
295295
with pytest.warns(UserWarning) as record:
296-
reactpy.Vdom("div")((1 for i in range(10)))
296+
reactpy.Vdom("div")(1 for i in range(10))
297297
assert len(record) == 1
298298
assert (
299299
record[0]

tests/test_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ def test_string_to_reactpy(case):
188188
# 8: Infer ReactJS `key` from the `key` attribute
189189
{
190190
"source": '<div key="my-key"></div>',
191-
"model": {"tagName": "div", "attributes": {"key": "my-key"}, "key": "my-key"},
191+
"model": {
192+
"tagName": "div",
193+
"attributes": {"key": "my-key"},
194+
"key": "my-key",
195+
},
192196
},
193197
],
194198
)

tests/test_web/test_module.py

Lines changed: 78 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -224,44 +224,47 @@ async def test_keys_properly_propagated(display: DisplayFixture):
224224
GridLayout = reactpy.web.export(module, "GridLayout")
225225

226226
await display.show(
227-
lambda: GridLayout({
228-
"layout": [
229-
{
230-
"i": "a",
231-
"x": 0,
232-
"y": 0,
233-
"w": 1,
234-
"h": 2,
235-
"static": True,
236-
},
237-
{
238-
"i": "b",
239-
"x": 1,
240-
"y": 0,
241-
"w": 3,
242-
"h": 2,
243-
"minW": 2,
244-
"maxW": 4,
245-
},
246-
{
247-
"i": "c",
248-
"x": 4,
249-
"y": 0,
250-
"w": 1,
251-
"h": 2,
252-
}
253-
],
254-
"cols": 12,
255-
"rowHeight": 30,
256-
"width": 1200,
257-
},
227+
lambda: GridLayout(
228+
{
229+
"layout": [
230+
{
231+
"i": "a",
232+
"x": 0,
233+
"y": 0,
234+
"w": 1,
235+
"h": 2,
236+
"static": True,
237+
},
238+
{
239+
"i": "b",
240+
"x": 1,
241+
"y": 0,
242+
"w": 3,
243+
"h": 2,
244+
"minW": 2,
245+
"maxW": 4,
246+
},
247+
{
248+
"i": "c",
249+
"x": 4,
250+
"y": 0,
251+
"w": 1,
252+
"h": 2,
253+
},
254+
],
255+
"cols": 12,
256+
"rowHeight": 30,
257+
"width": 1200,
258+
},
258259
reactpy.html.div({"key": "a"}, "a"),
259260
reactpy.html.div({"key": "b"}, "b"),
260261
reactpy.html.div({"key": "c"}, "c"),
261262
)
262263
)
263264

264-
parent = await display.page.wait_for_selector(".react-grid-layout", state="attached")
265+
parent = await display.page.wait_for_selector(
266+
".react-grid-layout", state="attached"
267+
)
265268
children = await parent.query_selector_all("div")
266269

267270
# The children simply will not render unless they receive the key prop
@@ -270,55 +273,52 @@ async def test_keys_properly_propagated(display: DisplayFixture):
270273

271274
async def test_subcomponent_notation_as_str_attrs(display: DisplayFixture):
272275
module = reactpy.web.module_from_file(
273-
"subcomponent-notation", JS_FIXTURES_DIR / "subcomponent-notation.js",
276+
"subcomponent-notation",
277+
JS_FIXTURES_DIR / "subcomponent-notation.js",
274278
)
275279
InputGroup, InputGroupText, FormControl, FormLabel = reactpy.web.export(
276-
module,
277-
["InputGroup", "InputGroup.Text", "Form.Control", "Form.Label"]
280+
module, ["InputGroup", "InputGroup.Text", "Form.Control", "Form.Label"]
278281
)
279282

280-
content = reactpy.html.div({"id": "the-parent"},
283+
content = reactpy.html.div(
284+
{"id": "the-parent"},
281285
InputGroup(
282286
InputGroupText({"id": "basic-addon1"}, "@"),
283-
FormControl({
284-
"placeholder": "Username",
285-
"aria-label": "Username",
286-
"aria-describedby": "basic-addon1",
287-
}),
287+
FormControl(
288+
{
289+
"placeholder": "Username",
290+
"aria-label": "Username",
291+
"aria-describedby": "basic-addon1",
292+
}
293+
),
288294
),
289-
290295
InputGroup(
291-
FormControl({
292-
"placeholder": "Recipient's username",
293-
"aria-label": "Recipient's username",
294-
"aria-describedby": "basic-addon2",
295-
}),
296+
FormControl(
297+
{
298+
"placeholder": "Recipient's username",
299+
"aria-label": "Recipient's username",
300+
"aria-describedby": "basic-addon2",
301+
}
302+
),
296303
InputGroupText({"id": "basic-addon2"}, "@example.com"),
297304
),
298-
299305
FormLabel({"htmlFor": "basic-url"}, "Your vanity URL"),
300306
InputGroup(
301-
InputGroupText({"id": "basic-addon3"},
302-
"https://example.com/users/"
303-
),
307+
InputGroupText({"id": "basic-addon3"}, "https://example.com/users/"),
304308
FormControl({"id": "basic-url", "aria-describedby": "basic-addon3"}),
305309
),
306-
307310
InputGroup(
308311
InputGroupText("$"),
309312
FormControl({"aria-label": "Amount (to the nearest dollar)"}),
310313
InputGroupText(".00"),
311314
),
312-
313315
InputGroup(
314316
InputGroupText("With textarea"),
315317
FormControl({"as": "textarea", "aria-label": "With textarea"}),
316-
)
318+
),
317319
)
318320

319-
await display.show(
320-
lambda: content
321-
)
321+
await display.show(lambda: content)
322322

323323
parent = await display.page.wait_for_selector("#the-parent", state="visible")
324324
input_group_text = await parent.query_selector_all(".input-group-text")
@@ -332,52 +332,50 @@ async def test_subcomponent_notation_as_str_attrs(display: DisplayFixture):
332332

333333
async def test_subcomponent_notation_as_obj_attrs(display: DisplayFixture):
334334
module = reactpy.web.module_from_file(
335-
"subcomponent-notation", JS_FIXTURES_DIR / "subcomponent-notation.js",
335+
"subcomponent-notation",
336+
JS_FIXTURES_DIR / "subcomponent-notation.js",
336337
)
337338
InputGroup, Form = reactpy.web.export(module, ["InputGroup", "Form"])
338339

339-
content = reactpy.html.div({"id": "the-parent"},
340+
content = reactpy.html.div(
341+
{"id": "the-parent"},
340342
InputGroup(
341343
InputGroup.Text({"id": "basic-addon1"}, "@"),
342-
Form.Control({
343-
"placeholder": "Username",
344-
"aria-label": "Username",
345-
"aria-describedby": "basic-addon1",
346-
}),
344+
Form.Control(
345+
{
346+
"placeholder": "Username",
347+
"aria-label": "Username",
348+
"aria-describedby": "basic-addon1",
349+
}
350+
),
347351
),
348-
349352
InputGroup(
350-
Form.Control({
351-
"placeholder": "Recipient's username",
352-
"aria-label": "Recipient's username",
353-
"aria-describedby": "basic-addon2",
354-
}),
353+
Form.Control(
354+
{
355+
"placeholder": "Recipient's username",
356+
"aria-label": "Recipient's username",
357+
"aria-describedby": "basic-addon2",
358+
}
359+
),
355360
InputGroup.Text({"id": "basic-addon2"}, "@example.com"),
356361
),
357-
358362
Form.Label({"htmlFor": "basic-url"}, "Your vanity URL"),
359363
InputGroup(
360-
InputGroup.Text({"id": "basic-addon3"},
361-
"https://example.com/users/"
362-
),
364+
InputGroup.Text({"id": "basic-addon3"}, "https://example.com/users/"),
363365
Form.Control({"id": "basic-url", "aria-describedby": "basic-addon3"}),
364366
),
365-
366367
InputGroup(
367368
InputGroup.Text("$"),
368369
Form.Control({"aria-label": "Amount (to the nearest dollar)"}),
369370
InputGroup.Text(".00"),
370371
),
371-
372372
InputGroup(
373373
InputGroup.Text("With textarea"),
374374
Form.Control({"as": "textarea", "aria-label": "With textarea"}),
375-
)
375+
),
376376
)
377377

378-
await display.show(
379-
lambda: content
380-
)
378+
await display.show(lambda: content)
381379

382380
parent = await display.page.wait_for_selector("#the-parent", state="visible")
383381
input_group_text = await parent.query_selector_all(".input-group-text")

0 commit comments

Comments
 (0)