Skip to content

warnings

__all__ = ('AdapterPackageNotFound', 'ConversionWarning') module-attribute

AdapterPackageNotFound

Bases: OptimadeWarning

The package for an adapter cannot be found.

Source code in optimade/adapters/warnings.py
6
7
class AdapterPackageNotFound(OptimadeWarning):
    """The package for an adapter cannot be found."""

ConversionWarning

Bases: OptimadeWarning

A non-critical error/fallback/choice happened during conversion of an entry to format.

Source code in optimade/adapters/warnings.py
10
11
class ConversionWarning(OptimadeWarning):
    """A non-critical error/fallback/choice happened during conversion of an entry to format."""

OptimadeWarning

Bases: Warning

Base Warning for the optimade package

Source code in optimade/warnings.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class OptimadeWarning(Warning):
    """Base Warning for the `optimade` package"""

    def __init__(
        self, detail: Optional[str] = None, title: Optional[str] = None, *args
    ) -> None:
        detail = detail if detail else self.__doc__
        super().__init__(detail, *args)
        self.detail = detail
        self.title = title if title else self.__class__.__name__

    def __repr__(self) -> str:
        attrs = {"detail": self.detail, "title": self.title}
        return "<{:s}({:s})>".format(
            self.__class__.__name__,
            " ".join(
                [
                    f"{attr}={value!r}"
                    for attr, value in attrs.items()
                    if value is not None
                ]
            ),
        )

    def __str__(self) -> str:
        return self.detail if self.detail is not None else ""