Skip to content

Attribute

Source code in src/library_analyzer/processing/api/model/_api.py
@dataclass(frozen=True)
class Attribute:
    id: str
    name: str
    types: AbstractType | None
    class_id: str | None = None

    @staticmethod
    def from_dict(d: dict[str, Any], class_id: str | None = None) -> Attribute:
        return Attribute(d["id"], d["name"], AbstractType.from_dict(d.get("types", {})), class_id)

    def to_dict(self) -> dict[str, Any]:
        types_json = self.types.to_dict() if self.types is not None else None
        return {"id": self.id, "name": self.name, "types": types_json}

class_id: str | None = None class-attribute instance-attribute

id: str instance-attribute

name: str instance-attribute

types: AbstractType | None instance-attribute

__init__(id, name, types, class_id=None)

from_dict(d, class_id=None) staticmethod

Source code in src/library_analyzer/processing/api/model/_api.py
@staticmethod
def from_dict(d: dict[str, Any], class_id: str | None = None) -> Attribute:
    return Attribute(d["id"], d["name"], AbstractType.from_dict(d.get("types", {})), class_id)

to_dict()

Source code in src/library_analyzer/processing/api/model/_api.py
def to_dict(self) -> dict[str, Any]:
    types_json = self.types.to_dict() if self.types is not None else None
    return {"id": self.id, "name": self.name, "types": types_json}