File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -127,4 +127,5 @@ def _settings_build_values(
127
127
env_file_encoding = None ,
128
128
env_nested_delimiter = None ,
129
129
secrets_dir = None ,
130
+ protected_namespaces = ('model_' , 'settings_' ),
130
131
)
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ classifiers = [
40
40
]
41
41
requires-python = ' >=3.7'
42
42
dependencies = [
43
- ' pydantic>=2.0a4 ' ,
43
+ ' pydantic>=2.0b1 ' ,
44
44
' python-dotenv>=0.21.0' ,
45
45
]
46
46
dynamic = [' version' ]
Original file line number Diff line number Diff line change 6
6
#
7
7
annotated-types==0.4.0
8
8
# via pydantic
9
- pydantic==2.0a4
9
+ pydantic==2.0b1
10
10
# via pydantic-settings (pyproject.toml)
11
- pydantic-core==0.30 .0
11
+ pydantic-core==0.38 .0
12
12
# via pydantic
13
13
python-dotenv==0.21.1
14
14
# via pydantic-settings (pyproject.toml)
Original file line number Diff line number Diff line change @@ -1614,3 +1614,19 @@ class Settings(BaseSettings):
1614
1614
assert s .v0 == 'v0'
1615
1615
assert s .sub_model .v1 == 'v1'
1616
1616
assert s .sub_model .v2 == b'v2'
1617
+
1618
+
1619
+ def test_protected_namespace_defaults ():
1620
+ # pydantic default
1621
+ with pytest .raises (NameError , match = 'Field "model_prefixed_field" has conflict with protected namespace "model_"' ):
1622
+
1623
+ class Model (BaseSettings ):
1624
+ model_prefixed_field : str
1625
+
1626
+ # pydantic-settings default
1627
+ with pytest .raises (
1628
+ NameError , match = 'Field "settings_prefixed_field" has conflict with protected namespace "settings_"'
1629
+ ):
1630
+
1631
+ class Model1 (BaseSettings ):
1632
+ settings_prefixed_field : str
You can’t perform that action at this time.
0 commit comments