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