flagsmith
flagsmith copied to clipboard
`util.pydantic.exclude_model_fields` fails when inside `freezegun.freeze_time`
trafficstars
The code here causes tests to fail with the following error:
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for [class 'datetime.datetime'](https://app.slack.com/client/TTKSY58MC/class%20'datetime.datetime'). 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.
Related discussion: https://github.com/pydantic/pydantic/discussions/9343
Currently, the way to fix this is to add the following to api/conftest.py:
def pytest_sessionstart(session):
from environments.sdk.schemas import SDKEnvironmentDocumentModel
A less hacky way to avoid the error would be something like
import freezegun
freezegun.configure(extend_ignore_list=["pydantic"])
but it will need a bit more trial and error to determine the exact module name to ignore.
Fixed by workaround applied in https://github.com/Flagsmith/flagsmith/pull/3876. We should in future be able to remove the workaround if/when freezegun resolves the issue, but the workaround is sufficient for now.