def get_annotation(var, cls):
 for annotation in getattr(var.tag, 'annotations', []):
  if isinstance(annotation, cls):
   return annotation

def get_annotation ( var , cls ) : for annotation in getattr ( var . tag , 'annotations' , [ ] ) : if isinstance ( annotation , cls ) : return annotation
a helper function to retrieve an annotation of a particular type .