mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
* adding BaseModel * initial version of the system model * creating setup functions and removing constants from config_terminal * removing log_supress const * fix test * merge * system handler * fix import * centralized configs setup * repr to use the BaseModel * updating i18n dict location * ignoring warning on wrong type-var * ruff * Update openbb_terminal/core/models/system_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Update openbb_terminal/core/models/system_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * import literal * loading env files before the plot backend is called * fix tests/openbb_terminal/test_terminal_helper.py * tests need to have i18n initialized * fix seeking_alpha tests --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
30 lines
861 B
Python
30 lines
861 B
Python
from typing import Any, Optional
|
|
|
|
from pydantic.dataclasses import dataclass
|
|
|
|
# pylint: disable=too-many-instance-attributes, disable=no-member
|
|
|
|
|
|
@dataclass
|
|
class BaseModel:
|
|
def __repr__(self) -> str:
|
|
"""Return string representation of model."""
|
|
dataclass_repr = ""
|
|
for key, value in self.__dict__.items():
|
|
if key.startswith("_"):
|
|
continue
|
|
dataclass_repr += f" {key}='{value}', \n"
|
|
|
|
return f"{self.__class__.__name__}(\n{dataclass_repr[:-2]}\n)"
|
|
|
|
@classmethod
|
|
def get_fields(cls) -> dict[str, Any]:
|
|
"""Get dict of fields."""
|
|
return cls.__dataclass_fields__ # type: ignore
|
|
|
|
def get_field_value(self, field: str) -> Optional[str]:
|
|
"""Get field value."""
|
|
if hasattr(self, field):
|
|
return getattr(self, field)
|
|
return None
|