Skip to content

Parameter

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

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

    def __init__(
        self,
        id_: str,
        name: str,
        qname: str,
        default_value: Optional[str],
        assigned_by: ParameterAssignment,
        is_public: bool,
        documentation: ParameterDocumentation,
    ) -> None:
        self.id: str = id_
        self.name: str = name
        self.qname: str = qname
        self.default_value: Optional[str] = default_value
        self.assigned_by: ParameterAssignment = assigned_by
        self.is_public: bool = is_public
        self.documentation = documentation
        self.type: Optional[AbstractType] = create_type(documentation)

    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_json(self) -> 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.documentation.to_dict(),
            "type": self.type.to_json() if self.type is not None else {},
        }

    def __repr__(self) -> str:
        return "Parameter(id=" + self.id + ")"

assigned_by: ParameterAssignment = assigned_by instance-attribute

default_value: Optional[str] = default_value instance-attribute

documentation = documentation 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: Optional[AbstractType] = create_type(documentation) instance-attribute

__hash__()

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

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

Source code in library_analyzer/processing/api/model/_parameters.py
def __init__(
    self,
    id_: str,
    name: str,
    qname: str,
    default_value: Optional[str],
    assigned_by: ParameterAssignment,
    is_public: bool,
    documentation: ParameterDocumentation,
) -> None:
    self.id: str = id_
    self.name: str = name
    self.qname: str = qname
    self.default_value: Optional[str] = default_value
    self.assigned_by: ParameterAssignment = assigned_by
    self.is_public: bool = is_public
    self.documentation = documentation
    self.type: Optional[AbstractType] = create_type(documentation)

__repr__()

Source code in library_analyzer/processing/api/model/_parameters.py
def __repr__(self) -> str:
    return "Parameter(id=" + self.id + ")"

from_json(json) staticmethod

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

is_optional()

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

is_required()

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

to_json()

Source code in library_analyzer/processing/api/model/_parameters.py
def to_json(self) -> 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.documentation.to_dict(),
        "type": self.type.to_json() if self.type is not None else {},
    }