Get annotations in memory which inherits from cls.

        :param tuple/type exclude: annotation type(s) to exclude from search.
        :return: found annotations which inherits from cls.
        :rtype: set
429368
def get_memory_annotations(cls, exclude=None):
        

        result = set()

        # get global dictionary
        annotations_in_memory = Annotation.__ANNOTATIONS_IN_MEMORY__

        exclude = () if exclude is None else exclude

        # iterate on annotation classes
        for annotation_cls in annotations_in_memory:

            # if annotation class is excluded, continue
            if issubclass(annotation_cls, exclude):
                continue

            # if annotation class inherits from self, add it in the result
            if issubclass(annotation_cls, cls):
                result |= annotations_in_memory[annotation_cls]

        return result
1328446
def annotation(self, type, set=None):
        """"""
        l = self.count(type,set,True,default_ignore_annotations)
        if len(l) >= 1:
            return l[0]
        else:
            raise NoSuchAnnotation()
509781
public static ImmutableSet<? extends AnnotationMirror> getAnnotatedAnnotations(Element element,
      final Class<? extends Annotation> annotationType) {
    List<? extends AnnotationMirror> annotations = element.getAnnotationMirrors();
    return FluentIterable.from(annotations)
        .filter(new Predicate<AnnotationMirror>() {
          @Override public boolean apply(AnnotationMirror input) {
            return isAnnotationPresent(input.getAnnotationType().asElement(), annotationType);
          }
        })
        .toSet();
  }
547338
protected Set<String> getExclusions(AnnotationMetadata metadata,
			AnnotationAttributes attributes) {
		Set<String> excluded = new LinkedHashSet<>();
		excluded.addAll(asList(attributes, "exclude"));
		excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
		excluded.addAll(getExcludeAutoConfigurationsProperty());
		return excluded;
	}
830382
public static Predicate<Class<?>> isAnnotatedWith(Class<? extends Annotation>... annotations) {
        return clazz -> {
            for (Class<? extends Annotation> annotation : annotations) {
                if (clazz.isAnnotationPresent(annotation)) {
                    return true;
                }
            }
            return false;
        };
    }
1205074
public static <T extends Annotation> Optional<T> getAnnotation( String annotation, List<? extends HasAnnotations>
            hasAnnotationsList ) {
        try {
            Class clazz = Class.forName( annotation );
            return getAnnotation( clazz, hasAnnotationsList );
        } catch ( ClassNotFoundException e ) {
            return Optional.absent();
        }
    }
756708
def get_tid2annotations(self, clean:bool=True):
        '''  '''
        tid2annotations = defaultdict(list)
        header = ['Index'] + list(self.fetch_annotations().columns)
        for row in self.fetch_annotations().itertuples():
            row = {header[i]:val for i, val in enumerate(row)}
            if clean:
                annotation = {
                    'tid': row['tid'],
                    'annotation_type_tid': row['annotation_type_tid'],
                    'value': row['value'],
                    'annotation_type_label': row['annotation_type_label'],
                }
                tid2annotations[row['tid']].append(annotation)
            elif not clean:
                tid2annotations[row['tid']].append(row)
        return tid2annotations
639569
def filter_annotations_by_ptype(function, ptype):
    ''''''
    ret = {}
    for k, v in function.__annotations__.items():
        if k == 'return':
            continue
        pt, _ = v
        if pt == ptype:
            ret[k] = v
    return ret
416903
@CheckForNull
    private <T extends BugAnnotation> T findPrimaryAnnotationOfType(Class<T> cls) {
        T firstMatch = null;
        for (Iterator<BugAnnotation> i = annotationIterator(); i.hasNext();) {
            BugAnnotation annotation = i.next();
            if (cls.isAssignableFrom(annotation.getClass())) {
                if (annotation.getDescription().endsWith("DEFAULT")) {
                    return cls.cast(annotation);
                } else if (firstMatch == null) {
                    firstMatch = cls.cast(annotation);
                }
            }
        }
        return firstMatch;
    }
382297
def remove_annotations(self, remove_sequence):
        
        return self._apply_to_annotations(lambda alist: tuple(oa for oa in alist if oa not in remove_sequence))
1296082
def in_memory(self):
        

        self_class = self.__class__
        # check if self class is in global memory
        memory = Annotation.__ANNOTATIONS_IN_MEMORY__.get(self_class, ())
        # check if self is in memory
        result = self in memory

        return result
909663
@SafeVarargs
	public final Set<Class<?>> scan(Class<? extends Annotation>... annotationTypes)
			throws ClassNotFoundException {
		List<String> packages = getPackages();
		if (packages.isEmpty()) {
			return Collections.emptySet();
		}
		ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
				false);
		scanner.setEnvironment(this.context.getEnvironment());
		scanner.setResourceLoader(this.context);
		for (Class<? extends Annotation> annotationType : annotationTypes) {
			scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType));
		}
		Set<Class<?>> entitySet = new HashSet<>();
		for (String basePackage : packages) {
			if (StringUtils.hasText(basePackage)) {
				for (BeanDefinition candidate : scanner
						.findCandidateComponents(basePackage)) {
					entitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
							this.context.getClassLoader()));
				}
			}
		}
		return entitySet;
	}
86133
def selections(self):
        """
        for sel in self._selections:
            if sel.annotation.axes is None:
                raise RuntimeError("Annotation unexpectedly removed; "
                                   "use 'cursor.remove_selection' instead")
        return tuple(self._selections)
245110
public static <T extends Annotation> Optional<T> getAnnotation( Class<T> annotation, List<? extends HasAnnotations>
            hasAnnotationsList ) {
        for ( HasAnnotations accessor : hasAnnotationsList ) {
            if ( accessor.isAnnotationPresent( annotation ) ) {
                return Optional.of( accessor.getAnnotation( annotation ) );
            }
        }
        return Optional.absent();
    }
1066507
public static <T extends Annotation> Set<Field> getAnnotatedFields(Class<? extends Object> clazz,
			Class<T> annotation) {
		if (Object.class.equals(clazz)) {
			return Collections.emptySet();
		}
		Set<Field> annotatedFields = new HashSet<Field>();
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			if (field.getAnnotation(annotation) != null) {
				annotatedFields.add(field);
			}
		}
		annotatedFields.addAll(getAnnotatedFields(clazz.getSuperclass(), annotation));
		return annotatedFields;
	}
862014
def free_memory(cls, exclude=None):
        """"""

        annotations_in_memory = Annotation.__ANNOTATIONS_IN_MEMORY__

        exclude = () if exclude is None else exclude

        for annotation_cls in list(annotations_in_memory.keys()):

            if issubclass(annotation_cls, exclude):
                continue

            if issubclass(annotation_cls, cls):
                del annotations_in_memory[annotation_cls]
1208068
def _get_type_hints(func, args = None, res = None, infer_defaults = None):
    
    if args is None or res is None:
        args2, res2 = _get_types(func, util.is_classmethod(func),
                util.is_method(func), unspecified_type = type(NotImplemented),
                infer_defaults = infer_defaults)
        if args is None:
            args = args2
        if res is None:
            res = res2
    slf = 1 if util.is_method(func) else 0
    argNames = util.getargnames(util.getargspecs(util._actualfunc(func)))
    result = {}
    if not args is Any:
        prms = get_Tuple_params(args)
        for i in range(slf, len(argNames)):
            if not prms[i-slf] is type(NotImplemented):
                result[argNames[i]] = prms[i-slf]
    result['return'] = res
    return result