Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GrafanaDashboard to a pydantic base model #23

Open
sed-i opened this issue Apr 5, 2024 · 0 comments
Open

Refactor GrafanaDashboard to a pydantic base model #23

sed-i opened this issue Apr 5, 2024 · 0 comments

Comments

@sed-i
Copy link
Contributor

sed-i commented Apr 5, 2024

Pydantic 2+ does not allow arbitrary types, so when this lib is consumed, we get a runtime error:

pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'cosl.grafana_dashboard.GrafanaDashboard'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

class GrafanaDashboard(str):

A workaround is to add

    class Config:
        arbitrary_types_allowed = True

to pydantic models that rely on it, but that is not a great solution. Instead we could refactor here into a pydantic base model.

Related: canonical/cos-proxy-operator#131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant