change output_type preference spec

This commit is contained in:
montezdesousa
2023-09-27 22:05:34 +01:00
parent c8a3968bd2
commit 4538126a53
2 changed files with 7 additions and 7 deletions

View File

@@ -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)

View File

@@ -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)()