MCPcopy
hub / github.com/plotly/dash / __new__

Method __new__

dash/development/base_component.py:63–90  ·  view source on GitHub ↗
(mcs, name, bases, attributes)

Source from the content-addressed store, hash-verified

61
62 # pylint: disable=arguments-differ
63 def __new__(mcs, name, bases, attributes):
64 module = attributes["__module__"].split(".")[0]
65
66 if attributes.get("_explicitize_dash_init", False):
67 # We only want to patch the new generated component without
68 # the `@_explicitize_args` decorator for mypy support
69 # See issue: https://github.com/plotly/dash/issues/3226
70 # Only for component that were generated by 3.0.3
71 # Better to setattr on the component afterwards to ensure
72 # backward compatibility.
73 attributes["__init__"] = _explicitize_args(attributes["__init__"])
74
75 _component = abc.ABCMeta.__new__(mcs, name, bases, attributes)
76
77 if name == "Component" or module == "builtins":
78 # Don't add to the registry the base component
79 # and the components loaded dynamically by load_component
80 # as it doesn't have the namespace.
81 return _component
82
83 _namespace = attributes.get("_namespace", module)
84 ComponentRegistry.namespace_to_package[_namespace] = module
85 ComponentRegistry.registry.add(module)
86 ComponentRegistry.children_props[_namespace][name] = attributes.get(
87 "_children_props"
88 )
89
90 return _component
91
92
93def is_number(s):

Callers

nothing calls this directly

Calls 3

_explicitize_argsFunction · 0.85
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected