Кравченко Роман, 420 InitParam 14524
Данила Ковтун, 428 группа InitParam 14207
n1from types import FunctionTypen1from types import FunctionType, GenericAlias
2import inspect2import inspect
33
4class init(type):4class init(type):
55
n6    def __new__(metaclass, name, parents, ns):n6    def __new__(metacls, name, parents, ns):
7        for (i, j) in ns.items():7        for (i, j) in ns.items():
8            if isinstance(j, FunctionType):8            if isinstance(j, FunctionType):
n9                lst = []n9                default = []
10                for (l, m) in inspect.signature(j).parameters.items():10                for (l, m) in inspect.signature(j).parameters.items():
11                    if not inspect._empty is m.annotation:11                    if not inspect._empty is m.annotation:
12                        try:12                        try:
n13                            lst.append(m.annotation())n13                            default.append(m.annotation())
14                        except:14                        except:
n15                            lst.append(None)n15                            default.append(None)
16                if j.__defaults__ is not None:16                if j.__defaults__ is not None:
t17                    l = len(j.__defaults__)t17                    length = len(j.__defaults__)
18                    lst[-l:] = j.__defaults__18                    default[-length:] = j.__defaults__
19                j.__defaults__ = tuple(lst)19                j.__defaults__ = tuple(default)
20        return super().__new__(metaclass, name, parents, ns)20        return super().__new__(metacls, name, parents, ns)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op