Skip to content

Commit 7ec55b9

Browse files
committed
Fix order of meta wrapping components.
1 parent cc7a0d0 commit 7ec55b9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

dash/development/base_component.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,20 @@ class ComponentMeta(abc.ABCMeta):
5252
# pylint: disable=arguments-differ
5353
def __new__(mcs, name, bases, attributes):
5454
module = attributes["__module__"].split(".")[0]
55+
56+
if attributes.get("_explicitize_dash_init", False):
57+
# We only want to patch the new generated component without
58+
# the `@_explicitize_args` decorator for mypy support
59+
# See issue: https://github.com/plotly/dash/issues/3226
60+
attributes["__init__"] = _explicitize_args(attributes["__init__"])
61+
62+
_component = abc.ABCMeta.__new__(mcs, name, bases, attributes)
63+
5564
if name == "Component" or module == "builtins":
56-
# Don't do the base component
65+
# Don't add to the registry the base component
5766
# and the components loaded dynamically by load_component
5867
# as it doesn't have the namespace.
59-
return abc.ABCMeta.__new__(mcs, name, bases, attributes)
68+
return _component
6069

6170
_namespace = attributes.get("_namespace", module)
6271
ComponentRegistry.namespace_to_package[_namespace] = module
@@ -65,13 +74,7 @@ def __new__(mcs, name, bases, attributes):
6574
"_children_props"
6675
)
6776

68-
if attributes.get("_explicitize_dash_init", False):
69-
# We only want to patch the new generated component without
70-
# the `@_explicitize_args` decorator for mypy support
71-
# See issue: https://github.com/plotly/dash/issues/3226
72-
attributes["__init__"] = _explicitize_args(attributes["__init__"])
73-
74-
return abc.ABCMeta.__new__(mcs, name, bases, attributes)
77+
return _component
7578

7679

7780
def is_number(s):

tests/unit/development/metadata_test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import typing # noqa: F401
44
import numbers # noqa: F401
55
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
6-
from dash.development.base_component import Component, _explicitize_args
6+
from dash.development.base_component import Component
77
try:
88
from dash.development.base_component import ComponentType # noqa: F401
99
except ImportError:
@@ -131,7 +131,8 @@ class Table(Component):
131131
}
132132
)
133133

134-
@_explicitize_args
134+
_explicitize_dash_init = True
135+
135136
def __init__(
136137
self,
137138
children: typing.Optional[typing.Union[str, int, float, ComponentType, typing.Sequence[typing.Union[str, int, float, ComponentType]]]] = None,

0 commit comments

Comments
 (0)