Skip to content

Commit d2d2be9

Browse files
committed
Fix type checker for NumberType implementation
1 parent f3a14f9 commit d2d2be9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

dash/development/_py_components_generation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222
import_string = """# AUTO GENERATED FILE - DO NOT EDIT
2323
2424
import typing # noqa: F401
25+
from typing import TYPE_CHECKING # noqa: F401
2526
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
2627
from dash.development.base_component import Component, _explicitize_args
27-
try:
28+
if TYPE_CHECKING:
2829
from dash.types import NumberType # noqa: F401
29-
except ImportError:
30-
NumberType = typing.Union[ # noqa: F401
31-
typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
32-
]
30+
else:
31+
try:
32+
from dash.types import NumberType # noqa: F401
33+
except ImportError:
34+
NumberType = typing.Union[ # noqa: F401
35+
typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
36+
]
3337
{custom_imports}
3438
ComponentSingleType = typing.Union[str, int, float, Component, None]
3539
ComponentType = typing.Union[

0 commit comments

Comments
 (0)