Generate a Python class object given a class string. Parameters ---------- typename props description namespace Returns -------
(
typename, props, description, namespace, prop_reorder_exceptions=None
)
| 310 | |
| 311 | |
| 312 | def generate_class( |
| 313 | typename, props, description, namespace, prop_reorder_exceptions=None |
| 314 | ): |
| 315 | """Generate a Python class object given a class string. |
| 316 | Parameters |
| 317 | ---------- |
| 318 | typename |
| 319 | props |
| 320 | description |
| 321 | namespace |
| 322 | Returns |
| 323 | ------- |
| 324 | """ |
| 325 | string = generate_class_string( |
| 326 | typename, props, description, namespace, prop_reorder_exceptions |
| 327 | ) |
| 328 | scope = { |
| 329 | "Component": Component, |
| 330 | "ComponentType": ComponentType, |
| 331 | "_explicitize_args": _explicitize_args, |
| 332 | "typing": typing, |
| 333 | "numbers": numbers, |
| 334 | "TypedDict": TypedDict, |
| 335 | "NotRequired": NotRequired, |
| 336 | "Literal": Literal, |
| 337 | "NumberType": typing.Union[ |
| 338 | typing.SupportsFloat, typing.SupportsComplex, typing.SupportsInt |
| 339 | ], |
| 340 | } |
| 341 | # pylint: disable=exec-used |
| 342 | exec(string, scope) |
| 343 | result = scope[typename] |
| 344 | return result |
| 345 | |
| 346 | |
| 347 | def required_props(props): |
searching dependent graphs…