mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
use FutureWarning in settings so it's printed (#881)
* use FutureWarning in settings so it's printed * fix tests * better warning link * change warning link
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Use `FutureWarning` instead of `DeprecationWarning` when `alias` instead of `env` is used for settings models
|
||||
@@ -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):
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user