Кирнев Юрий, 321 группа AnnoDoc 16439
Файзуллов Айрат Рафагатович 530 группа AnnoDoc 17236
f1class AnnoDoc(type):f1class AnnoDoc(type):
22
n3    def __new__(cls, name, bases, dct):n3    def __new__(cls, nm, b, d):
4        orig = dct.get('__doc__', '')4        base_doc = d.get('__doc__', '')
5        new = []5        extra_doc = []
6        ann = dct.get('__annotations__', {}).copy()6        annotations = d.get('__annotations__', {}).copy()
7        keys = list(ann.keys())7        keys = list(annotations.keys())
8        for attr in keys:8        for key in keys:
9            a = ann[attr]9            annotation = annotations[key]
10            if isinstance(a, str):10            if isinstance(annotation, str):
11                new.append(f'{attr}: {a}')11                extra_doc.append(f'{key}: {annotation}')
12                if attr in dct:12                if key in d:
13                    value = dct[attr]13                    value = d[key]
14                    ann[attr] = type(value)14                    annotations[key] = type(value)
15                else:15                else:
n16                    del ann[attr]n16                    del annotations[key]
17        if orig:17        if base_doc:
18            dct['__doc__'] = orig + '\n' + '\n'.join(new)18            d['__doc__'] = base_doc + '\n' + '\n'.join(extra_doc)
19        elif new != []:19        elif extra_doc:
20            dct['__doc__'] = '\n'.join(new)20            d['__doc__'] = '\n'.join(extra_doc)
21        else:21        else:
t22            dct['__doc__'] = Nonet22            d['__doc__'] = None
23        dct['__annotations__'] = ann23        d['__annotations__'] = annotations
24        return super().__new__(cls, name, bases, dct)24        return super().__new__(cls, nm, b, d)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op