Skip to content

Commit 1ae86a0

Browse files
committed
Fix test_generate_class_file
1 parent a7569df commit 1ae86a0

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

tests/unit/development/metadata_test.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

33
import typing # noqa: F401
4-
import numbers # noqa: F401
54
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
6-
from dash.development.base_component import Component
7-
try:
8-
from dash.development.base_component import ComponentType # noqa: F401
9-
except ImportError:
10-
ComponentType = typing.TypeVar("ComponentType", bound=Component)
5+
from dash.development.base_component import Component, _explicitize_args
6+
7+
ComponentType = typing.Union[
8+
str,
9+
int,
10+
float,
11+
Component,
12+
None,
13+
typing.Sequence[typing.Union[str, int, float, Component, None]],
14+
]
15+
16+
NumberType = typing.Union[
17+
typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
18+
]
1119

1220

1321
class Table(Component):
@@ -109,7 +117,7 @@ class Table(Component):
109117
"OptionalObjectWithExactAndNestedDescription",
110118
{
111119
"color": NotRequired[str],
112-
"fontSize": NotRequired[typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex]],
120+
"fontSize": NotRequired[NumberType],
113121
"figure": NotRequired["OptionalObjectWithExactAndNestedDescriptionFigure"]
114122
}
115123
)
@@ -126,30 +134,29 @@ class Table(Component):
126134
"OptionalObjectWithShapeAndNestedDescription",
127135
{
128136
"color": NotRequired[str],
129-
"fontSize": NotRequired[typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex]],
137+
"fontSize": NotRequired[NumberType],
130138
"figure": NotRequired["OptionalObjectWithShapeAndNestedDescriptionFigure"]
131139
}
132140
)
133141

134-
_explicitize_dash_init = True
135142

136143
def __init__(
137144
self,
138-
children: typing.Optional[typing.Union[str, int, float, ComponentType, typing.Sequence[typing.Union[str, int, float, ComponentType]]]] = None,
145+
children: typing.Optional[ComponentType] = None,
139146
optionalArray: typing.Optional[typing.Sequence] = None,
140147
optionalBool: typing.Optional[bool] = None,
141148
optionalFunc: typing.Optional[typing.Any] = None,
142-
optionalNumber: typing.Optional[typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex]] = None,
149+
optionalNumber: typing.Optional[NumberType] = None,
143150
optionalObject: typing.Optional[dict] = None,
144151
optionalString: typing.Optional[str] = None,
145152
optionalSymbol: typing.Optional[typing.Any] = None,
146-
optionalNode: typing.Optional[typing.Union[str, int, float, ComponentType, typing.Sequence[typing.Union[str, int, float, ComponentType]]]] = None,
147-
optionalElement: typing.Optional[ComponentType] = None,
153+
optionalNode: typing.Optional[ComponentType] = None,
154+
optionalElement: typing.Optional[Component] = None,
148155
optionalMessage: typing.Optional[typing.Any] = None,
149156
optionalEnum: typing.Optional[Literal["News", "Photos"]] = None,
150-
optionalUnion: typing.Optional[typing.Union[str, typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex], typing.Any]] = None,
151-
optionalArrayOf: typing.Optional[typing.Sequence[typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex]]] = None,
152-
optionalObjectOf: typing.Optional[typing.Dict[typing.Union[str, float, int], typing.Union[typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex]]] = None,
157+
optionalUnion: typing.Optional[typing.Union[str, NumberType, typing.Any]] = None,
158+
optionalArrayOf: typing.Optional[typing.Sequence[NumberType]] = None,
159+
optionalObjectOf: typing.Optional[typing.Dict[typing.Union[str, float, int], NumberType]] = None,
153160
optionalObjectWithExactAndNestedDescription: typing.Optional["OptionalObjectWithExactAndNestedDescription"] = None,
154161
optionalObjectWithShapeAndNestedDescription: typing.Optional["OptionalObjectWithShapeAndNestedDescription"] = None,
155162
optionalAny: typing.Optional[typing.Any] = None,
@@ -168,3 +175,5 @@ def __init__(
168175
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
169176

170177
super(Table, self).__init__(children=children, **args)
178+
179+
setattr(Table, "__init__", _explicitize_args(Table.__init__))

tests/unit/development/test_generate_class_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def expected_class_string():
3333

3434
@pytest.fixture
3535
def component_class_string(make_component_dir):
36-
return import_string + generate_class_string(
36+
return import_string.format(custom_imports="") + generate_class_string(
3737
typename="Table",
3838
props=make_component_dir["props"],
3939
description=make_component_dir["description"],

0 commit comments

Comments
 (0)