My class looks something like this:
class MyConfig(BaseSettings):
model_config = SettingsConfigDict(
env_file=get_configs(),
)
I didn’t realize that my get_configs()
seems to be getting called on import. I discovered this when I had a bug in that function and pytest collection was failing.
Is this a python behavior or something specific to how the model_config
attribute of the BaseSettings
class works? It doesn’t make sense to me because I would expect my get_configs()
function to only get called when the code that is actually instantiating MyConfig
is executed.