Skip to content

ConstantAnnotation

Bases: ValueAnnotation

Source code in src/library_analyzer/processing/annotations/model/_annotations.py
@dataclass
class ConstantAnnotation(ValueAnnotation):
    variant = ValueAnnotation.Variant.CONSTANT
    defaultValueType: ValueAnnotation.DefaultValueType  # noqa: N815
    defaultValue: Any  # noqa: N815

    @staticmethod
    def from_dict(d: dict[str, Any]) -> ConstantAnnotation:
        annotation = AbstractAnnotation.from_dict(d)
        return ConstantAnnotation(
            annotation.target,
            annotation.authors,
            annotation.reviewers,
            annotation.comment,
            annotation.reviewResult,
            ValueAnnotation.DefaultValueType(d["defaultValueType"]),
            d["defaultValue"],
        )

    def to_dict(self) -> dict[str, Any]:
        return {
            "target": self.target,
            "authors": self.authors,
            "reviewers": self.reviewers,
            "comment": self.comment,
            "reviewResult": self.reviewResult.value,
            "variant": self.variant.value,
            "defaultValueType": self.defaultValueType.value,
            "defaultValue": self.defaultValue,
        }

defaultValue: Any instance-attribute

defaultValueType: ValueAnnotation.DefaultValueType instance-attribute

variant = ValueAnnotation.Variant.CONSTANT class-attribute instance-attribute

__init__(target, authors, reviewers, comment, reviewResult, defaultValueType, defaultValue)

from_dict(d) staticmethod

Source code in src/library_analyzer/processing/annotations/model/_annotations.py
@staticmethod
def from_dict(d: dict[str, Any]) -> ConstantAnnotation:
    annotation = AbstractAnnotation.from_dict(d)
    return ConstantAnnotation(
        annotation.target,
        annotation.authors,
        annotation.reviewers,
        annotation.comment,
        annotation.reviewResult,
        ValueAnnotation.DefaultValueType(d["defaultValueType"]),
        d["defaultValue"],
    )

to_dict()

Source code in src/library_analyzer/processing/annotations/model/_annotations.py
def to_dict(self) -> dict[str, Any]:
    return {
        "target": self.target,
        "authors": self.authors,
        "reviewers": self.reviewers,
        "comment": self.comment,
        "reviewResult": self.reviewResult.value,
        "variant": self.variant.value,
        "defaultValueType": self.defaultValueType.value,
        "defaultValue": self.defaultValue,
    }