Data Models and Exceptions (models)ο
This module is the core of the libraryβs data contract, responsible for enforcing data integrity and providing clear error signals. It leverages Pydantic to transform unstructured API responses into robust, type-safe Python objects.
By defining clear data models, this module ensures that all data consumed by the application layer is valid and predictable.
Data Models
- class ChemInformant.models.Compound(*, cid: int, input_identifier: str | int, MolecularFormula: str | None = None, MolecularWeight: float | None = None, CanonicalSMILES: str | None = None, IsomericSMILES: str | None = None, IUPACName: str | None = None, XLogP: float | None = None, cas: str | None = None, description: str | None = None, synonyms: ~typing.List[str] = <factory>)[source]ο
Bases:
BaseModel
A Pydantic model representing a chemical compound from PubChem.
This class serves as a structured data container for the information retrieved from the API, providing type hints and validation.
- pubchem_urlο
A computed property with the direct link to the compoundβs PubChem page.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}ο
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Custom Exceptions