nodes: 0, module; 1, function_definition; 2, function_name:get_annotations; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:target; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, expression_statement; 16, expression_statement; 17, if_statement; 18, if_statement; 19, return_statement; 20, identifier:exclude; 21, None; 22, identifier:ctx; 23, None; 24, identifier:select; 25, lambda; 26, identifier:mindepth; 27, integer:0; 28, identifier:maxdepth; 29, integer:0; 30, identifier:followannotated; 31, True; 32, identifier:public; 33, True; 34, identifier:_history; 35, None; 36, comment:"""Returns all input target annotations of cls type sorted
          by definition order.
  
          :param type cls: type of annotation to get from target.
          :param target: target from where get annotations.
          :param tuple/type exclude: annotation types to remove from selection.
          :param ctx: target ctx.
          :param select: bool function which select annotations after applying
              previous type filters. Takes a target, a ctx and an annotation in
              parameters. True by default.
          :param int mindepth: minimal depth for searching annotations (default 0)
          :param int maxdepth: maximal depth for searching annotations (default 0)
          :param bool followannotated: if True (default) follow deeply only
              annotated members.
          :param bool public: if True (default) follow public members.
          :param list _history: private parameter which save parsed elements.
          :rtype: Annotation
          """; 37, assignment; 38, comparison_operator:mindepth <= 0; 39, block; 40, boolean_operator; 41, block; 42, identifier:result; 43, lambda_parameters; 44, True; 45, identifier:result; 46, list; 47, identifier:mindepth; 48, integer:0; 49, try_statement; 50, if_statement; 51, expression_statement; 52, for_statement; 53, comparison_operator:mindepth >= 0; 54, parenthesized_expression; 55, if_statement; 56, for_statement; 57, list_splat_pattern; 58, block; 59, except_clause; 60, not_operator; 61, block; 62, assignment; 63, pattern_list; 64, identifier:annotations_by_ctx; 65, block; 66, identifier:mindepth; 67, integer:0; 68, boolean_operator; 69, comparison_operator:_history is None; 70, block; 71, else_clause; 72, pattern_list; 73, call; 74, block; 75, identifier:p; 76, expression_statement; 77, identifier:TypeError; 78, block; 79, identifier:annotations_by_ctx; 80, if_statement; 81, identifier:exclude; 82, conditional_expression:() if exclude is None else exclude; 83, identifier:elt; 84, identifier:annotations; 85, for_statement; 86, comparison_operator:maxdepth > 0; 87, parenthesized_expression; 88, identifier:_history; 89, None; 90, expression_statement; 91, block; 92, identifier:name; 93, identifier:member; 94, identifier:getmembers; 95, argument_list; 96, if_statement; 97, assignment; 98, expression_statement; 99, call; 100, block; 101, elif_clause; 102, tuple; 103, comparison_operator:exclude is None; 104, identifier:exclude; 105, identifier:annotation; 106, identifier:annotations; 107, comment:# check if annotation is a StopPropagation rule; 108, block; 109, identifier:maxdepth; 110, integer:0; 111, boolean_operator; 112, assignment; 113, expression_statement; 114, identifier:target; 115, boolean_operator; 116, block; 117, identifier:annotations_by_ctx; 118, call; 119, assignment; 120, identifier:ismethod; 121, argument_list; 122, expression_statement; 123, expression_statement; 124, if_statement; 125, call; 126, block; 127, identifier:exclude; 128, None; 129, if_statement; 130, comment:# ensure propagation; 131, if_statement; 132, comment:# ensure overriding; 133, if_statement; 134, comment:# check for annotation; 135, if_statement; 136, identifier:result; 137, not_operator; 138, identifier:_history; 139, list; 140, call; 141, parenthesized_expression; 142, comparison_operator:member not in _history; 143, if_statement; 144, expression_statement; 145, identifier:get_property; 146, argument_list; 147, identifier:annotations_by_ctx; 148, dictionary; 149, identifier:target; 150, assignment; 151, assignment; 152, not_operator; 153, block; 154, identifier:isfunction; 155, argument_list; 156, expression_statement; 157, call; 158, block; 159, boolean_operator; 160, block; 161, attribute; 162, block; 163, parenthesized_expression; 164, block; 165, identifier:followannotated; 166, identifier:target; 167, attribute; 168, argument_list; 169, boolean_operator; 170, identifier:member; 171, identifier:_history; 172, boolean_operator; 173, block; 174, augmented_assignment; 175, keyword_argument; 176, keyword_argument; 177, keyword_argument; 178, identifier:func; 179, call; 180, identifier:annotations_by_ctx; 181, call; 182, identifier:annotations_by_ctx; 183, expression_statement; 184, identifier:target; 185, assignment; 186, identifier:isinstance; 187, argument_list; 188, expression_statement; 189, comparison_operator:elt is not target; 190, not_operator; 191, continue_statement; 192, identifier:annotation; 193, identifier:override; 194, expression_statement; 195, boolean_operator; 196, expression_statement; 197, identifier:_history; 198, identifier:append; 199, identifier:target; 200, comparison_operator:name[0] != '_'; 201, not_operator; 202, call; 203, call; 204, continue_statement; 205, identifier:result; 206, call; 207, identifier:elt; 208, identifier:target; 209, identifier:key; 210, attribute; 211, identifier:ctx; 212, identifier:ctx; 213, identifier:get_method_function; 214, argument_list; 215, identifier:get_property; 216, argument_list; 217, assignment; 218, identifier:annotations_by_ctx; 219, call; 220, identifier:annotation; 221, identifier:StopPropagation; 222, augmented_assignment; 223, identifier:elt; 224, identifier:target; 225, attribute; 226, augmented_assignment; 227, boolean_operator; 228, call; 229, call; 230, subscript; 231, string; 232, identifier:public; 233, identifier:ismethod; 234, argument_list; 235, attribute; 236, argument_list; 237, attribute; 238, argument_list; 239, identifier:Annotation; 240, identifier:__ANNOTATIONS_KEY__; 241, identifier:target; 242, keyword_argument; 243, keyword_argument; 244, keyword_argument; 245, identifier:annotations_by_ctx; 246, call; 247, identifier:get_property; 248, argument_list; 249, identifier:exclude; 250, attribute; 251, identifier:annotation; 252, identifier:propagate; 253, identifier:exclude; 254, tuple; 255, call; 256, not_operator; 257, identifier:select; 258, argument_list; 259, attribute; 260, argument_list; 261, identifier:name; 262, integer:0; 263, string_content:_; 264, identifier:target; 265, identifier:name; 266, identifier:startswith; 267, string; 268, identifier:cls; 269, identifier:get_annotations; 270, keyword_argument; 271, keyword_argument; 272, keyword_argument; 273, keyword_argument; 274, keyword_argument; 275, keyword_argument; 276, keyword_argument; 277, keyword_argument; 278, identifier:elt; 279, identifier:func; 280, identifier:key; 281, attribute; 282, identifier:ctx; 283, identifier:ctx; 284, identifier:get_property; 285, argument_list; 286, keyword_argument; 287, keyword_argument; 288, identifier:annotation; 289, identifier:annotation_types; 290, attribute; 291, identifier:isinstance; 292, argument_list; 293, call; 294, identifier:target; 295, identifier:ctx; 296, identifier:annotation; 297, identifier:result; 298, identifier:append; 299, identifier:annotation; 300, string_content:im_; 301, identifier:target; 302, identifier:member; 303, identifier:exclude; 304, identifier:exclude; 305, identifier:ctx; 306, identifier:ctx; 307, identifier:select; 308, identifier:select; 309, identifier:mindepth; 310, binary_operator:mindepth - 1; 311, identifier:maxdepth; 312, binary_operator:maxdepth - 1; 313, identifier:followannotated; 314, identifier:followannotated; 315, identifier:_history; 316, identifier:_history; 317, identifier:Annotation; 318, identifier:__ANNOTATIONS_KEY__; 319, keyword_argument; 320, keyword_argument; 321, identifier:elt; 322, identifier:target; 323, identifier:key; 324, attribute; 325, identifier:annotation; 326, identifier:__class__; 327, identifier:annotation; 328, identifier:cls; 329, identifier:isinstance; 330, argument_list; 331, identifier:mindepth; 332, integer:1; 333, identifier:maxdepth; 334, integer:1; 335, identifier:elt; 336, identifier:func; 337, identifier:key; 338, attribute; 339, identifier:Annotation; 340, identifier:__ANNOTATIONS_KEY__; 341, identifier:annotation; 342, identifier:exclude; 343, identifier:Annotation; 344, identifier:__ANNOTATIONS_KEY__
code: def get_annotations(
              cls, target,
              exclude=None, ctx=None, select=lambda *p: True,
              mindepth=0, maxdepth=0, followannotated=True, public=True,
              _history=None
      ):
          """Returns all input target annotations of cls type sorted
          by definition order.
  
          :param type cls: type of annotation to get from target.
          :param target: target from where get annotations.
          :param tuple/type exclude: annotation types to remove from selection.
          :param ctx: target ctx.
          :param select: bool function which select annotations after applying
              previous type filters. Takes a target, a ctx and an annotation in
              parameters. True by default.
          :param int mindepth: minimal depth for searching annotations (default 0)
          :param int maxdepth: maximal depth for searching annotations (default 0)
          :param bool followannotated: if True (default) follow deeply only
              annotated members.
          :param bool public: if True (default) follow public members.
          :param list _history: private parameter which save parsed elements.
          :rtype: Annotation
          """
  
          result = []
  
          if mindepth <= 0:
  
              try:
                  annotations_by_ctx = get_property(
                      elt=target, key=Annotation.__ANNOTATIONS_KEY__, ctx=ctx
                  )
  
              except TypeError:
                  annotations_by_ctx = {}
  
              if not annotations_by_ctx:
                  if ismethod(target):
                      func = get_method_function(target)
                      annotations_by_ctx = get_property(
                          elt=func,
                          key=Annotation.__ANNOTATIONS_KEY__,
                          ctx=ctx
                      )
                      if not annotations_by_ctx:
                          annotations_by_ctx = get_property(
                              elt=func, key=Annotation.__ANNOTATIONS_KEY__
                          )
                  elif isfunction(target):
                      annotations_by_ctx = get_property(
                          elt=target,
                          key=Annotation.__ANNOTATIONS_KEY__
                      )
  
              exclude = () if exclude is None else exclude
  
              for elt, annotations in annotations_by_ctx:
  
                  for annotation in annotations:
  
                      # check if annotation is a StopPropagation rule
                      if isinstance(annotation, StopPropagation):
                          exclude += annotation.annotation_types
  
                      # ensure propagation
                      if elt is not target and not annotation.propagate:
                          continue
  
                      # ensure overriding
                      if annotation.override:
                          exclude += (annotation.__class__, )
  
                      # check for annotation
                      if (isinstance(annotation, cls)
                              and not isinstance(annotation, exclude)
                              and select(target, ctx, annotation)):
  
                          result.append(annotation)
  
          if mindepth >= 0 or (maxdepth > 0 and (result or not followannotated)):
  
              if _history is None:
                  _history = [target]
  
              else:
                  _history.append(target)
  
              for name, member in getmembers(target):
                  if (name[0] != '_' or not public) and member not in _history:
  
                      if ismethod(target) and name.startswith('im_'):
                          continue
  
                      result += cls.get_annotations(
                          target=member, exclude=exclude, ctx=ctx, select=select,
                          mindepth=mindepth - 1, maxdepth=maxdepth - 1,
                          followannotated=followannotated, _history=_history
                      )
  
          return result