f | class AnnoDoc(type): | f | class AnnoDoc(type): |
| | | |
n | def __new__(metacls, cls_name, cls_bases, cls_dict): | n | def __new__(cls, class_name, base_classes, class_dict): |
| cls_instance = super().__new__(metacls, cls_name, cls_bases, cls | | created_class = super().__new__(cls, class_name, base_classes, c |
| _dict) | | lass_dict) |
| doc_parts = [] | | doc_content = [] |
| if cls_instance.__doc__: | | if created_class.__doc__: |
| doc_parts.append(cls_instance.__doc__) | | doc_content.append(created_class.__doc__) |
| annots = {} | | type_annotations = {} |
| for attr_name, attr_type in cls_dict.get('__annotations__', {}). | | for attribute, annotation in class_dict.get('__annotations__', { |
| items(): | | }).items(): |
| if isinstance(attr_type, str): | | if isinstance(annotation, str): |
| doc_parts.append(f'{attr_name}: {attr_type}') | | doc_content.append(f'{attribute}: {annotation}') |
| if attr_name not in cls_dict: | | if attribute not in class_dict: |
| continue | | continue |
t | annots[attr_name] = type(cls_dict[attr_name]) if attr_name i | t | type_annotations[attribute] = type(class_dict[attribute]) if |
| n cls_dict else attr_type | | attribute in class_dict else annotation |
| cls_instance.__doc__ = '\n'.join(doc_parts) if doc_parts else No | | created_class.__doc__ = '\n'.join(doc_content) if doc_content el |
| ne | | se None |
| cls_instance.__annotations__ = annots | | created_class.__annotations__ = type_annotations |
| return cls_instance | | return created_class |