Removed ConfigModel from_dict
All checks were successful
All checks were successful
This commit is contained in:
@@ -115,18 +115,7 @@ class Configuration:
|
||||
if sub.__name__ != key and sub.__name__.replace("Settings", "") != key:
|
||||
continue
|
||||
|
||||
configuration = sub()
|
||||
from_dict = getattr(configuration, "from_dict", None)
|
||||
|
||||
if from_dict is not None and not hasattr(from_dict, "is_base_func"):
|
||||
Console.set_foreground_color(ForegroundColorEnum.yellow)
|
||||
Console.write_line(
|
||||
f"{sub.__name__}.from_dict is deprecated. Instead, set attributes as typed arguments in __init__. They can be None by default!"
|
||||
)
|
||||
Console.color_reset()
|
||||
configuration.from_dict(value)
|
||||
else:
|
||||
configuration = JSONProcessor.process(sub, value)
|
||||
configuration = JSONProcessor.process(sub, value)
|
||||
|
||||
cls.set(sub, configuration)
|
||||
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
def base_func(method):
|
||||
method.is_base_func = True
|
||||
return method
|
||||
from abc import ABC
|
||||
|
||||
|
||||
class ConfigurationModelABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
r"""ABC for settings representation"""
|
||||
|
||||
@base_func
|
||||
def from_dict(self, settings: dict):
|
||||
r"""DEPRECATED: Set attributes as typed arguments in __init__ instead. See https://docs.sh-edraft.de/cpl/deprecated.html#ConfigurationModelABC-from_dict-method for further information
|
||||
Converts attributes to dict
|
||||
|
||||
Parameter:
|
||||
settings: :class:`dict`
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
from cpl.core.log import LoggerABC
|
||||
from model.user_repo_abc import UserRepoABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
from model.user_repo import UserRepo
|
||||
from model.user_repo_abc import UserRepoABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
Reference in New Issue
Block a user