Skip to content

Commit e4300ad

Browse files
dennisbakhuisDennis Bakhuis
andauthored
fixed types annotations for meta in add_page() to accept components (#6012)
* fixed types for meta in add_page() to accept Sequence[Mapping[str, str] | Component] * standardized types; corrected type of test * ran pre-commit all-files --------- Co-authored-by: Dennis Bakhuis <[email protected]>
1 parent c60147b commit e4300ad

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

reflex/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class UnevaluatedPage:
297297
description: Var | str | None
298298
image: str
299299
on_load: EventType[()] | None
300-
meta: Sequence[Mapping[str, str]]
300+
meta: Sequence[Mapping[str, Any] | Component]
301301
context: Mapping[str, Any]
302302

303303
def merged_with(self, other: UnevaluatedPage) -> UnevaluatedPage:
@@ -772,7 +772,7 @@ def add_page(
772772
description: str | Var | None = None,
773773
image: str = constants.DefaultPage.IMAGE,
774774
on_load: EventType[()] | None = None,
775-
meta: list[dict[str, str]] = constants.DefaultPage.META_LIST,
775+
meta: Sequence[Mapping[str, Any] | Component] = constants.DefaultPage.META_LIST,
776776
context: dict[str, Any] | None = None,
777777
):
778778
"""Add a page to the app.

reflex/compiler/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def add_meta(
562562
page: Component,
563563
title: str,
564564
image: str,
565-
meta: list[dict],
565+
meta: Sequence[Mapping[str, Any] | Component],
566566
description: str | None = None,
567567
) -> Component:
568568
"""Add metadata to a page.

tests/units/test_page.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def load_foo():
3131
title="Foo",
3232
image="foo.png",
3333
description="Foo description",
34-
meta=["foo-meta"],
34+
meta=[{"name": "keywords", "content": "foo, test"}],
3535
script_tags=["foo-script"],
3636
on_load=load_foo,
3737
)(foo_)
@@ -41,7 +41,7 @@ def load_foo():
4141
assert page_data == {
4242
"description": "Foo description",
4343
"image": "foo.png",
44-
"meta": ["foo-meta"],
44+
"meta": [{"name": "keywords", "content": "foo, test"}],
4545
"on_load": load_foo,
4646
"route": "foo",
4747
"script_tags": ["foo-script"],

0 commit comments

Comments
 (0)