Skip to content

ValueAnnotation

Bases: AbstractAnnotation, ABC

Source code in library_analyzer/processing/annotations/model/_annotations.py
class ValueAnnotation(AbstractAnnotation, ABC):
    class Variant(Enum):
        CONSTANT = "constant"
        OMITTED = "omitted"
        OPTIONAL = "optional"
        REQUIRED = "required"

    class DefaultValueType(Enum):
        BOOLEAN = "boolean"
        NONE = "none"
        NUMBER = "number"
        STRING = "string"

    variant: Variant

    @staticmethod
    def from_json(json: Any) -> ValueAnnotation:
        variant = json["variant"]
        if ValueAnnotation.Variant.CONSTANT.value == variant:
            return ConstantAnnotation.from_json(json)
        if ValueAnnotation.Variant.OMITTED.value == variant:
            return OmittedAnnotation.from_json(json)
        if ValueAnnotation.Variant.OPTIONAL.value == variant:
            return OptionalAnnotation.from_json(json)
        if ValueAnnotation.Variant.REQUIRED.value == variant:
            return RequiredAnnotation.from_json(json)
        raise Exception("unkonwn variant found")

variant: Variant class-attribute

DefaultValueType

Bases: Enum

Source code in library_analyzer/processing/annotations/model/_annotations.py
class DefaultValueType(Enum):
    BOOLEAN = "boolean"
    NONE = "none"
    NUMBER = "number"
    STRING = "string"

BOOLEAN = 'boolean' class-attribute

NONE = 'none' class-attribute

NUMBER = 'number' class-attribute

STRING = 'string' class-attribute

Variant

Bases: Enum

Source code in library_analyzer/processing/annotations/model/_annotations.py
class Variant(Enum):
    CONSTANT = "constant"
    OMITTED = "omitted"
    OPTIONAL = "optional"
    REQUIRED = "required"

CONSTANT = 'constant' class-attribute

OMITTED = 'omitted' class-attribute

OPTIONAL = 'optional' class-attribute

REQUIRED = 'required' class-attribute

from_json(json) staticmethod

Source code in library_analyzer/processing/annotations/model/_annotations.py
@staticmethod
def from_json(json: Any) -> ValueAnnotation:
    variant = json["variant"]
    if ValueAnnotation.Variant.CONSTANT.value == variant:
        return ConstantAnnotation.from_json(json)
    if ValueAnnotation.Variant.OMITTED.value == variant:
        return OmittedAnnotation.from_json(json)
    if ValueAnnotation.Variant.OPTIONAL.value == variant:
        return OptionalAnnotation.from_json(json)
    if ValueAnnotation.Variant.REQUIRED.value == variant:
        return RequiredAnnotation.from_json(json)
    raise Exception("unkonwn variant found")