Жан-Юль-Ян Азель, 414 группа (КФ) AnnoDoc 17163
Исанбеков Дамир 414 КФ AnnoDoc 17126
f1class AnnoDoc(type):f1class AnnoDoc(type):
22
n3    def __new__(metacls, cls_name, cls_bases, cls_dict):n3    def __new__(cls, class_name, base_classes, class_dict):
4        cls_instance = super().__new__(metacls, cls_name, cls_bases, cls4        created_class = super().__new__(cls, class_name, base_classes, c
>_dict)>lass_dict)
5        doc_parts = []5        doc_content = []
6        if cls_instance.__doc__:6        if created_class.__doc__:
7            doc_parts.append(cls_instance.__doc__)7            doc_content.append(created_class.__doc__)
8        annots = {}8        type_annotations = {}
9        for attr_name, attr_type in cls_dict.get('__annotations__', {}).9        for attribute, annotation in class_dict.get('__annotations__', {
>items():>}).items():
10            if isinstance(attr_type, str):10            if isinstance(annotation, str):
11                doc_parts.append(f'{attr_name}: {attr_type}')11                doc_content.append(f'{attribute}: {annotation}')
12                if attr_name not in cls_dict:12                if attribute not in class_dict:
13                    continue13                    continue
t14            annots[attr_name] = type(cls_dict[attr_name]) if attr_name it14            type_annotations[attribute] = type(class_dict[attribute]) if
>n cls_dict else attr_type> attribute in class_dict else annotation
15        cls_instance.__doc__ = '\n'.join(doc_parts) if doc_parts else No15        created_class.__doc__ = '\n'.join(doc_content) if doc_content el
>ne>se None
16        cls_instance.__annotations__ = annots16        created_class.__annotations__ = type_annotations
17        return cls_instance17        return created_class
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op