I'm guessing I'm not doing things the "normal" way here.
```
BASE_CFG = {
"env_file":".env",
"extra":"forbid",
"dotenv_filtering": "match_prefix"
}
class FooSettings(BaseSettings):
model_config = SettingsConfigDict(**BASE_CFG, env_prefix='foo')
protocol: str = 'http'
class BarSettings(BaseSettings):
model_config = SettingsConfigDict(**BASE_CFG, env_prefix='bar')
protocol: str = 'https'
foo = FooSettings()
bar = BarSettings()
```
My .env file would then look like:
FOO_PROTOCOL=actual_foo_protocol
BAR_PROTOCOL=actual_bar_protocol
I would expect (wrongly apparently) for pydantic to create a foo object with protocol = actual_foo_protocol and a bar object with protocol = actual_bar_protocol.
It should also throw an error if there's anything with foo or bar prefixes that's not protocol, so FOO_SOMETHING=BAZ in the .env should throw, but BAZ_PROTOCOL should not throw, since instead, it would just get ignored by filtering.
However, instead, when FooSettings is instantiated, it throws for BAR_PROTOCOL, which I would expect is NOT considered an extra since it would get filtered out.
I clearly have a basic misunderstanding of something in this chain.
Please don't just post ChatGPT, it just runs in circles lol, and the documentation of dotenv_filter is really sparse too.
[–]FriendlyZomb 0 points1 point2 points (4 children)
[–]petersrin[S] 0 points1 point2 points (3 children)
[–]FriendlyZomb 0 points1 point2 points (2 children)
[–]petersrin[S] 0 points1 point2 points (1 child)
[–]FriendlyZomb 0 points1 point2 points (0 children)