diff --git a/changes/881-samuelcolvin.md b/changes/881-samuelcolvin.md new file mode 100644 index 0000000..457f323 --- /dev/null +++ b/changes/881-samuelcolvin.md @@ -0,0 +1 @@ +Use `FutureWarning` instead of `DeprecationWarning` when `alias` instead of `env` is used for settings models diff --git a/pydantic/env_settings.py b/pydantic/env_settings.py index 6fdb8b5..2adc96f 100644 --- a/pydantic/env_settings.py +++ b/pydantic/env_settings.py @@ -73,8 +73,9 @@ class BaseSettings(BaseModel): if field.has_alias: warnings.warn( 'aliases are no longer used by BaseSettings to define which environment variables to read. ' - 'Instead use the "env" field setting. See https://pydantic-docs.helpmanual.io/usage/settings/', - DeprecationWarning, + 'Instead use the "env" field setting. ' + 'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names', + FutureWarning, ) env_names = [cls.env_prefix + field.name] elif isinstance(env, str): diff --git a/tests/test_settings.py b/tests/test_settings.py index c709099..d0a6ff4 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -208,7 +208,7 @@ def test_env_field(env): def test_aliases_warning(env): - with pytest.warns(DeprecationWarning, match='aliases are no longer used by BaseSettings'): + with pytest.warns(FutureWarning, match='aliases are no longer used by BaseSettings'): class Settings(BaseSettings): foobar: str = 'default value'