Spaces:
Running
on
Zero
Running
on
Zero
File size: 437 Bytes
f499d3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from abc import ABC, abstractmethod
from dataclasses import fields
class ConfigSpec(ABC):
@classmethod
def check_keys(cls, config):
expect = [field.name for field in fields(cls)]
for key in config.keys():
if key not in expect:
raise ValueError(f"expect names {expect} in {cls.__name__}, found {key}")
@classmethod
@abstractmethod
def parse(cls, config):
pass
|