MCPcopy Create free account
hub / github.com/Materials-Consortia/optimade-python-tools / Warnings

Class Warnings

optimade/models/optimade_json.py:166–192  ·  view source on GitHub ↗

OPTIMADE-specific warning class based on OPTIMADE-specific JSON API Error. From the specification: A warning resource object is defined similarly to a JSON API error object, but MUST also include the field type, which MUST have the value "warning". The field detail MUST be present and

Source from the content-addressed store, hash-verified

164
165
166class Warnings(OptimadeError):
167 """OPTIMADE-specific warning class based on OPTIMADE-specific JSON API Error.
168
169 From the specification:
170
171 A warning resource object is defined similarly to a JSON API error object, but MUST also include the field type, which MUST have the value "warning".
172 The field detail MUST be present and SHOULD contain a non-critical message, e.g., reporting unrecognized search attributes or deprecated features.
173
174 Note: Must be named "Warnings", since "Warning" is a built-in Python class.
175
176 """
177
178 model_config = ConfigDict(json_schema_extra=warnings_json_schema_extra)
179
180 type: Annotated[
181 Literal["warning"],
182 StrictField(
183 description='Warnings must be of type "warning"',
184 pattern="^warning$",
185 ),
186 ] = "warning"
187
188 @model_validator(mode="after")
189 def status_must_not_be_specified(self) -> "Warnings":
190 if self.status or "status" in self.model_fields_set:
191 raise ValueError("status MUST NOT be specified for warnings")
192 return self
193
194
195class ResponseMetaQuery(BaseModel):

Callers 1

showwarningMethod · 0.90

Calls 1

StrictFieldFunction · 0.90

Tested by

no test coverage detected