Skip to main content

is_anno_item

FunctionSource

flag: TypeGuard[AnnoItem] = is_anno_item(data: Any)

Implementation of isinstance(data, AnnoItem).

Aliases

This function can be acquired by

import dash_picture_annotation as dpa


dpa.is_anno_item
dpa.typehints.is_anno_item

Arguments

Requires

ArgumentTypeRequired
Description
dataAnyThe value to be verified.

Returns

ArgumentType
Description
flagboolIf this value is True, data an instance of AnnoItem, vice versa.

Examples

Check whether an object is an AnnoItem

check_is_anno_item.py
import dash_picture_annotation as dpa


mark: dpa.AnnoMark = {"x": 1, "y": 2, "width": 1, "height": 1, "type": "RECT"}

print(dpa.is_anno_item({}))
print(dpa.is_anno_item({"id": "test"}))
print(dpa.is_anno_item({"id": "test", "mark": mark}))
print(dpa.is_anno_item({"id": "test", "mark": mark, "comment": "test"}))
print(dpa.is_anno_item({"id": "test", "mark": mark, "comment": "test", "x": 1}))
print(dpa.is_anno_item({"id": "test", "mark": mark, "comment": 5}))