make config class a better interface

This commit is contained in:
Maximilian Keßler 2022-02-06 21:26:55 +01:00
parent 66b597d90c
commit 426e5a7d66
2 changed files with 14 additions and 15 deletions

View file

@ -3,7 +3,20 @@ from pathlib import Path
class Config:
pass
def merge_with(self, other, strict: bool = False):
"""
Merges the other config into this one
:param other:
:param strict: whether conflicting options are allowed or not
:return: self
"""
for var in vars(self):
if not getattr(self, var):
setattr(self, var, getattr(other, var))
else:
if strict and getattr(other, var) is not None and getattr(self, var) != getattr(other, var):
raise NotImplementedError
return self
class FormatterIF:

View file

@ -53,20 +53,6 @@ class FormattingConfig(Config):
def from_yaml(cls, yaml):
pass
def merge_with(self, other, strict: bool = False):
"""
Merges the other config into this one
:param other:
:param strict: whether conflicting options are allowed or not
:return: self
"""
for var in vars(self):
if not getattr(self, var):
setattr(self, var, getattr(other, var))
else:
if strict and getattr(other, var) is not None and getattr(self, var) != getattr(other, var):
raise NotImplementedError
return self
@property
def naming_scheme(self) -> NamingScheme: