mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-21 09:18:12 +00:00
fix: prediction import with pydantic-typed bodies (#1152)
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Respect pydantic model in serializing json data for import. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@ from akkudoktoreos.prediction.feedintarifffixed import FeedInTariffFixedCommonSe
|
||||
from akkudoktoreos.prediction.feedintariffimport import FeedInTariffImportCommonSettings
|
||||
|
||||
|
||||
def elecprice_provider_ids() -> list[str]:
|
||||
def feedintariff_provider_ids() -> list[str]:
|
||||
"""Valid feedintariff provider ids."""
|
||||
try:
|
||||
prediction_eos = get_prediction()
|
||||
@@ -67,14 +67,14 @@ class FeedInTariffCommonSettings(SettingsBaseModel):
|
||||
@property
|
||||
def providers(self) -> list[str]:
|
||||
"""Available feed in tariff provider ids."""
|
||||
return elecprice_provider_ids()
|
||||
return feedintariff_provider_ids()
|
||||
|
||||
# Validators
|
||||
@field_validator("provider", mode="after")
|
||||
@classmethod
|
||||
def validate_provider(cls, value: Optional[str]) -> Optional[str]:
|
||||
if value is None or value in elecprice_provider_ids():
|
||||
if value is None or value in feedintariff_provider_ids():
|
||||
return value
|
||||
raise ValueError(
|
||||
f"Provider '{value}' is not a valid feed in tariff provider: {elecprice_provider_ids()}."
|
||||
f"Provider '{value}' is not a valid feed in tariff provider: {feedintariff_provider_ids()}."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user