Skip to content

OptionalAnnotation

Bases: ValueAnnotation

Source code in library_analyzer/processing/annotations/model/_annotations.py
@dataclass
class OptionalAnnotation(ValueAnnotation):
    variant = ValueAnnotation.Variant.OPTIONAL
    defaultValueType: ValueAnnotation.DefaultValueType
    defaultValue: Any

    def to_json(self) -> dict:
        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,
        }

    @staticmethod
    def from_json(json: Any) -> OptionalAnnotation:
        annotation = AbstractAnnotation.from_json(json)
        return OptionalAnnotation(
            annotation.target,
            annotation.authors,
            annotation.reviewers,
            annotation.comment,
            annotation.reviewResult,
            ValueAnnotation.DefaultValueType(json["defaultValueType"]),
            json["defaultValue"],
        )

defaultValue: Any class-attribute

defaultValueType: ValueAnnotation.DefaultValueType class-attribute

variant = ValueAnnotation.Variant.OPTIONAL class-attribute

from_json(json) staticmethod

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

to_json()

Source code in library_analyzer/processing/annotations/model/_annotations.py
def to_json(self) -> dict:
    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,
    }