Skip to content

Parameter

Source code in src/library_analyzer/processing/api/model/_api.py
class Parameter:
    @staticmethod
    def from_dict(d: dict[str, Any]) -> Parameter:
        return Parameter(
            d["id"],
            d["name"],
            d["qname"],
            d.get("default_value", None),
            ParameterAssignment[d.get("assigned_by", "POSITION_OR_NAME")],
            d.get("is_public", True),
            ParameterDocstring.from_dict(d.get("docstring", {})),
        )

    def __hash__(self) -> int:
        return hash(
            (
                self.id,
                self.name,
                self.qname,
                self.default_value,
                self.assigned_by,
                self.is_public,
                self.docstring,
            ),
        )

    def __eq__(self, other: object) -> bool:
        return (
            isinstance(other, Parameter)
            and self.id == other.id
            and self.name == other.name
            and self.qname == other.qname
            and self.default_value == other.default_value
            and self.assigned_by == other.assigned_by
            and self.is_public == other.is_public
            and self.docstring == other.docstring
            and self.type == other.type
        )

    def __init__(
        self,
        id_: str,
        name: str,
        qname: str,
        default_value: str | None,
        assigned_by: ParameterAssignment,
        is_public: bool,
        docstring: ParameterDocstring,
    ) -> None:
        self.id: str = id_
        self.name: str = name
        self.qname: str = qname
        self.default_value: str | None = default_value
        self.assigned_by: ParameterAssignment = assigned_by
        self.is_public: bool = is_public
        self.docstring = docstring
        self.type: AbstractType | None = create_type(docstring)

    def is_optional(self) -> bool:
        return self.default_value is not None

    def is_required(self) -> bool:
        return self.default_value is None

    def to_dict(self) -> dict[str, Any]:
        return {
            "id": self.id,
            "name": self.name,
            "qname": self.qname,
            "default_value": self.default_value,
            "assigned_by": self.assigned_by.name,
            "is_public": self.is_public,
            "docstring": self.docstring.to_dict(),
            "type": self.type.to_dict() if self.type is not None else {},
        }

assigned_by: ParameterAssignment = assigned_by instance-attribute

default_value: str | None = default_value instance-attribute

docstring = docstring instance-attribute

id: str = id_ instance-attribute

is_public: bool = is_public instance-attribute

name: str = name instance-attribute

qname: str = qname instance-attribute

type: AbstractType | None = create_type(docstring) instance-attribute

__eq__(other)

Source code in src/library_analyzer/processing/api/model/_api.py
def __eq__(self, other: object) -> bool:
    return (
        isinstance(other, Parameter)
        and self.id == other.id
        and self.name == other.name
        and self.qname == other.qname
        and self.default_value == other.default_value
        and self.assigned_by == other.assigned_by
        and self.is_public == other.is_public
        and self.docstring == other.docstring
        and self.type == other.type
    )

__hash__()

Source code in src/library_analyzer/processing/api/model/_api.py
def __hash__(self) -> int:
    return hash(
        (
            self.id,
            self.name,
            self.qname,
            self.default_value,
            self.assigned_by,
            self.is_public,
            self.docstring,
        ),
    )

__init__(id_, name, qname, default_value, assigned_by, is_public, docstring)

Source code in src/library_analyzer/processing/api/model/_api.py
def __init__(
    self,
    id_: str,
    name: str,
    qname: str,
    default_value: str | None,
    assigned_by: ParameterAssignment,
    is_public: bool,
    docstring: ParameterDocstring,
) -> None:
    self.id: str = id_
    self.name: str = name
    self.qname: str = qname
    self.default_value: str | None = default_value
    self.assigned_by: ParameterAssignment = assigned_by
    self.is_public: bool = is_public
    self.docstring = docstring
    self.type: AbstractType | None = create_type(docstring)

from_dict(d) staticmethod

Source code in src/library_analyzer/processing/api/model/_api.py
@staticmethod
def from_dict(d: dict[str, Any]) -> Parameter:
    return Parameter(
        d["id"],
        d["name"],
        d["qname"],
        d.get("default_value", None),
        ParameterAssignment[d.get("assigned_by", "POSITION_OR_NAME")],
        d.get("is_public", True),
        ParameterDocstring.from_dict(d.get("docstring", {})),
    )

is_optional()

Source code in src/library_analyzer/processing/api/model/_api.py
def is_optional(self) -> bool:
    return self.default_value is not None

is_required()

Source code in src/library_analyzer/processing/api/model/_api.py
def is_required(self) -> bool:
    return self.default_value is None

to_dict()

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