MCPcopy
hub / github.com/nonebot/nonebot2 / model_fields

Function model_fields

nonebot/compat.py:227–237  ·  view source on GitHub ↗

Get field list of a model.

(model: type[BaseModel])

Source from the content-addressed store, hash-verified

225 return self.type_adapter.validate_python(value)
226
227 def model_fields(model: type[BaseModel]) -> list[ModelField]:
228 """Get field list of a model."""
229
230 return [
231 ModelField._construct(
232 name=name,
233 annotation=field_info.rebuild_annotation(),
234 field_info=FieldInfo._inherit_construct(field_info),
235 )
236 for name, field_info in model.model_fields.items()
237 ]
238
239 def model_config(model: type[BaseModel]) -> Any:
240 """Get config of a model."""

Callers 2

_next_fieldMethod · 0.90
__call__Method · 0.90

Calls 4

_inherit_constructMethod · 0.80
_constructMethod · 0.45
itemsMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected