MCPcopy Create free account
hub / github.com/dot-agent/nextpy / __init_subclass__

Method __init_subclass__

nextpy/frontend/components/component.py:169–189  ·  view source on GitHub ↗

Set default properties. Args: **kwargs: The kwargs to pass to the superclass.

(cls, **kwargs)

Source from the content-addressed store, hash-verified

167
168 @classmethod
169 def __init_subclass__(cls, **kwargs):
170 """Set default properties.
171
172 Args:
173 **kwargs: The kwargs to pass to the superclass.
174 """
175 super().__init_subclass__(**kwargs)
176
177 # Get all the props for the component.
178 props = cls.get_props()
179
180 # Convert fields to props, setting default values.
181 for field in cls.get_fields().values():
182 # If the field is not a component prop, skip it.
183 if field.name not in props:
184 continue
185
186 # Set default values for any props.
187 if types._issubclass(field.type_, Var):
188 field.required = False
189 field.default = Var.create(field.default)
190
191 def __init__(self, *args, **kwargs):
192 """Initialize the component.

Callers

nothing calls this directly

Calls 3

get_fieldsMethod · 0.80
get_propsMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected