pydantic_grammar module¶
A grammar based on a pydantic model.
- class gemseo.core.grammars.pydantic_grammar.PydanticGrammar(name, model=None, **kwargs)[source]
Bases:
BaseGrammar
A grammar based on a pydantic model.
The pydantic model passed to the grammar is used to initialize the grammar defaults. Currently, changing the defaults will not update the model.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
name (str) – The name of the grammar.
model (ModelType | None) – A pydantic model. If
None
, the model will be empty.**kwargs (Any) – These arguments are not used.
- Raises:
ValueError – If the name is empty.
- is_array(name, numeric_only=False)[source]
Check if an element is an array.
- set_descriptions(descriptions)[source]
Set the properties descriptions.
- DATA_CONVERTER_CLASS: ClassVar[str] = 'PydanticGrammarDataConverter'
The class or the class name of the data converter.
- from_namespaced: NamespacesMapping
The mapping from element names with namespace prefix to element names without namespace prefix.
- name: str
The name of the grammar.
- to_namespaced: NamespacesMapping
The mapping from element names without namespace prefix to element names with namespace prefix.