Skip to content

ImpurityReason

Bases: ABC

Superclass for impurity reasons.

If a function is impure it is because of one or more impurity reasons.

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
class ImpurityReason(ABC):  # this is just a base class, and it is important that it cannot be instantiated
    """Superclass for impurity reasons.

    If a function is impure it is because of one or more impurity reasons.
    """

    @abstractmethod
    def __str__(self) -> str:
        pass

    def __hash__(self) -> int:
        return hash(str(self))

    @abstractmethod
    def to_dict(self) -> dict[str, Any]:
        pass

__hash__()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def __hash__(self) -> int:
    return hash(str(self))

__str__() abstractmethod

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
@abstractmethod
def __str__(self) -> str:
    pass

to_dict() abstractmethod

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
@abstractmethod
def to_dict(self) -> dict[str, Any]:
    pass