| Total Complexity | 4 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| 1 | """Converter classes.""" |
||
| 31 | 1 | class Container(Mappable, Converter, metaclass=ABCMeta): |
|
| 32 | """Base class for mutable attribute converters.""" |
||
| 33 | |||
| 34 | 1 | @classmethod |
|
| 35 | def create_default(cls): |
||
| 36 | 1 | return cls.__new__(cls) |
|
| 37 | |||
| 38 | 1 | @classmethod |
|
| 39 | def to_value(cls, data): |
||
| 40 | 1 | value = cls.create_default() |
|
| 41 | 1 | value.update_value(data, auto_attr=True) |
|
| 42 | 1 | return value |
|
| 43 | |||
| 44 | 1 | @abstractmethod |
|
| 45 | def update_value(self, data, *, auto_attr): # pragma: no cover (abstract method) |
||
| 46 | """Update the attribute's value from loaded data.""" |
||
| 47 | raise NotImplementedError(common.OVERRIDE_MESSAGE) |
||
| 48 | |||
| 49 | 1 | def format_data(self): |
|
| 50 | """Format the attribute to data optimized for dumping.""" |
||
| 51 | return self.to_data(self) |
||
| 52 |