File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,13 @@ def __new__(
80
80
):
81
81
meta_conf = None
82
82
83
+ if "Config" in namespace :
84
+ config_keys = {k for k , _ in getmembers (namespace ["Config" ])}
85
+ if any (k in config_keys for k in MetaConf .model_fields .keys ()):
86
+ raise ConfigError (
87
+ "class `Config` cannot be used to configure ModelSchema. Use `Meta` instead"
88
+ )
89
+
83
90
if "Meta" in namespace :
84
91
conf_class = namespace ["Meta" ]
85
92
conf_dict = {
Original file line number Diff line number Diff line change @@ -132,10 +132,29 @@ class Meta:
132
132
fields = "__all__"
133
133
134
134
class CategorySchema5 (ModelSchema ):
135
- class Config :
135
+ class Meta :
136
136
model = Category
137
137
fields = "__all__"
138
138
139
+ with pytest .raises (
140
+ ConfigError ,
141
+ match = f"Field title from model { Category } already exists in the Schema" ,
142
+ ):
143
+
144
+ class CategorySchema6 (CategorySchema5 ):
145
+ class Meta (CategorySchema5 .Meta ):
146
+ fields = ["title" ]
147
+
148
+ with pytest .raises (
149
+ ConfigError ,
150
+ match = "class `Config` cannot be used to configure ModelSchema. Use `Meta` instead" ,
151
+ ):
152
+
153
+ class CategorySchema7 (ModelSchema ):
154
+ class Config :
155
+ model = Category
156
+ fields = "__all__"
157
+
139
158
140
159
def test_optional ():
141
160
class OptModel (models .Model ):
You can’t perform that action at this time.
0 commit comments