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