Return a subclass with alternative constructor that extends any original keyword arguments to the original constructor with the given options.
(cls, **options)
| 479 | |
| 480 | @classmethod |
| 481 | def with_options(cls, **options): |
| 482 | """Return a subclass with alternative constructor that extends any original keyword arguments to the original constructor with the given options.""" |
| 483 | class cls_with_options(cls): # type: ignore[misc, valid-type] |
| 484 | def __init__(self, *args, **kwargs): |
| 485 | kwargs.update(options) |
| 486 | super().__init__(*args, **kwargs) |
| 487 | |
| 488 | return cls_with_options |
| 489 | |
| 490 | def __init__(self, *args, **kwargs) -> None: |
| 491 | super().__init__(*args, **kwargs) |