mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 13:44:16 +00:00
change output_type preference spec
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, PositiveInt
|
||||
|
||||
@@ -19,9 +19,9 @@ class Preferences(BaseModel):
|
||||
table_style: Literal["dark", "light"] = "dark"
|
||||
request_timeout: PositiveInt = 15
|
||||
metadata: bool = True
|
||||
output_type: Optional[
|
||||
Literal["to_dataframe", "to_df", "to_polars", "to_numpy", "to_dict", "to_chart"]
|
||||
] = Field(default=None, description="Method to apply to OBBject by default.")
|
||||
output_type: Literal[
|
||||
"OBBject", "dataframe", "polars", "numpy", "dict", "chart"
|
||||
] = Field(default="OBBject", description="Method to apply to OBBject by default.")
|
||||
|
||||
model_config = ConfigDict(validate_assignment=True)
|
||||
|
||||
|
||||
@@ -17,6 +17,6 @@ class Container:
|
||||
"""Run a command in the container."""
|
||||
obbject = self._command_runner.run(*args, **kwargs)
|
||||
output_type = self._command_runner.user_settings.preferences.output_type
|
||||
if output_type:
|
||||
return getattr(obbject, output_type)()
|
||||
return obbject
|
||||
if output_type == "OBBject":
|
||||
return obbject
|
||||
return getattr(obbject, "to_" + output_type)()
|
||||
|
||||
Reference in New Issue
Block a user