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:
Samuel Colvin
2019-10-10 13:24:23 +01:00
committed by GitHub
parent f3dd39c1bb
commit bd8918bfab
3 changed files with 5 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
Use `FutureWarning` instead of `DeprecationWarning` when `alias` instead of `env` is used for settings models
+3 -2
View File
@@ -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):
+1 -1
View File
@@ -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'