Skip to content

UnknownProto

Bases: Unknown

Class for UnknownCalls which are not fully determined.

Attributes:

Name Type Description
symbol Symbol | Reference

The symbol or reference object which is not fully determined.

origin Symbol | NodeID | None

The origin of the unknown call.

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
@dataclass
class UnknownProto(Unknown):
    """Class for UnknownCalls which are not fully determined.

    Attributes
    ----------
    symbol :
        The symbol or reference object which is not fully determined.
    origin :
        The origin of the unknown call.
    """

    symbol: Symbol | Reference
    origin: Symbol | NodeID | None = field(default=None)  # TODO: remove NodeID

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

    def __str__(self) -> str:
        return f"{self.__class__.__name__}: {self.symbol.__class__.__name__}.{self.symbol.name}"

    def to_dict(self) -> dict[str, Any]:
        origin = (
            self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
        )
        return {
            "origin": f"{origin}",
            "reason": f"{self.symbol.name}",
        }

origin: Symbol | NodeID | None = field(default=None) class-attribute instance-attribute

symbol: Symbol | Reference instance-attribute

__hash__()

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

__init__(symbol, origin=None)

__str__()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def __str__(self) -> str:
    return f"{self.__class__.__name__}: {self.symbol.__class__.__name__}.{self.symbol.name}"

to_dict()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def to_dict(self) -> dict[str, Any]:
    origin = (
        self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
    )
    return {
        "origin": f"{origin}",
        "reason": f"{self.symbol.name}",
    }