Skip to content

Commit 97feada

Browse files
migeed-zmeta-codesync[bot]
authored andcommitted
Add failing base settings testcase
Summary: This is a wrong program to write and we don't raise an error. #1639 Reviewed By: rchen152 Differential Revision: D87591372 fbshipit-source-id: 9aedb275941b02b9b70d9008e0d3564e0eb461ae
1 parent 566cb77 commit 97feada

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pyrefly/lib/test/pydantic/base_settings.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,18 @@ os.environ["PORT"] = "8080"
2929
config = AppConfig() # E: Missing argument `database_url` in function `AppConfig.__init__` # E: Missing argument `api_key` in function `AppConfig.__init__` # E: Missing argument `port` in function `AppConfig.__init__`
3030
"#,
3131
);
32+
33+
pydantic_testcase!(
34+
bug = "This is not a correct program to write since a model cannot be both a BaseSettings and a RootModel",
35+
test_base_settings_wrong_def,
36+
r#"
37+
from pydantic_settings import BaseSettings
38+
from pydantic import RootModel
39+
40+
class AppConfig(BaseSettings, RootModel):
41+
database_url: str
42+
api_key: str
43+
port: int
44+
45+
"#,
46+
);

0 commit comments

Comments
 (0)