Skip to content

Commit

Permalink
прокидываю обычный get из словаря, чтобы выбрать элемент из конфига
Browse files Browse the repository at this point in the history
  • Loading branch information
Андрей Козлюк committed Mar 26, 2022
1 parent fea610b commit 6d3e28d
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions para_tri_dataset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
SYSTEM_CONFIG_FIELDS = ["__nested_configs__", "__val_schema__"]


class CustomNone:
pass


NONE_ = CustomNone()


class Config:
def __init__(self, name: str, data: dict, nested_configs, type_: str = "__main__"):
self.name = name
Expand All @@ -31,11 +24,8 @@ def __repr__(self):

return f"Config(name={self.name}, type={self.type_}, data=({data_part}), nested_configs=({nested_part}))"

def get(self, key: str, default_value: Union[Any, CustomNone] = NONE_):
if isinstance(default_value, CustomNone):
return self.data[key]
else:
return self.data.get(key, default_value)
def get(self, key: str, default_value: Optional[Any] = None):
return self.data.get(key, default_value)

def get_nested_config(self, key: str) -> "Config":
for nested_config in self.nested_configs:
Expand Down

0 comments on commit 6d3e28d

Please sign in to comment.