8000 use FutureWarning in settings so it's printed (#881) · ag-python/pydantic@bd8918b · GitHub
[go: up one dir, main page]

Skip to content

Commit bd8918b

Browse files
authored
use FutureWarning in settings so it's printed (pydantic#881)
* use FutureWarning in settings so it's printed * fix tests * better warning link * change warning link
1 parent f3dd39c commit bd8918b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

changes/881-samuelcolvin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `FutureWarning` instead of `DeprecationWarning` when `alias` instead of `env` is used for settings models

pydantic/env_settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def prepare_field(cls, field: ModelField) -> None:
7373
if field.has_alias:
7474
warnings.warn(
7575
'aliases are no longer used by BaseSettings to define which environment variables to read. '
76-
'Instead use the "env" field setting. See https://pydantic-docs.helpmanual.io/usage/settings/',
77-
DeprecationWarning,
76+
'Instead use the "env" field setting. '
77+
'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names',
78+
FutureWarning,
7879
)
7980
env_names = [cls.env_prefix + field.name]
8081
elif isinstance(env, str):

tests/test_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class Settings(BaseSettings):
208208

209209

210210
def test_aliases_warning(env):
211-
with pytest.warns(DeprecationWarning, match='aliases are no longer used by BaseSettings'):
211+
with pytest.warns(FutureWarning, match='aliases are no longer used by BaseSettings'):
212212

213213
class Settings(BaseSettings):
214214
foobar: str = 'default value'

0 commit comments

Comments
 (0)
0