Search code examples
pydanticpydantic-settings

In Pydantic, is model_config a reserved keyword?


I got an error while running my script that lead me to this documentation page:

model_config is used as a model field

This error is raised when model_config is used as the name of a field.

Apparently in Pydantic it is an error to use model_config as a model field. However, I have other code where it is used like that and no problem occurrs.

Is model_config a keyword in later versions of Pydantic?


Solution

  • It is, as you pointed out in the documentation!

    You aren't the only one that got the bad surprise. example

    This is new in version 2.7 so your other code likely runs an older version, where it is not a reserved keyword