configclass¶
configclass(cls=None)
¶
Construct a Config in dataclass
style.
This decorator creates a Config instance with the provided class attributes.
See Also
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls |
Type[Any]
|
The class to be enhanced, provided directly if no parentheses are used. |
None
|
Returns:
Type | Description |
---|---|
A modified class with Config functionalities or a decorator with bound parameters. |
Examples:
Python Console Session
>>> @configclass
... class DataloaderConfig:
... batch_size: int = 64
... num_workers: int = 4
... pin_memory: bool = True
>>> config = DataloaderConfig()
>>> print(config)
DataloaderConfig(<class 'chanfig.config.Config'>,
('batch_size'): 64
('num_workers'): 4
('pin_memory'): True
)