n | from types import FunctionType, GenericAlias | n | from types import FunctionType |
| import inspect | | import inspect |
| | | |
| class init(type): | | class init(type): |
| | | |
n | def __new__(metacls, name, parents, ns): | n | def __new__(metaclass, name, parents, ns): |
| for (i, j) in ns.items(): | | for (i, j) in ns.items(): |
| if isinstance(j, FunctionType): | | if isinstance(j, FunctionType): |
n | default = [] | n | lst = [] |
| for (l, m) in inspect.signature(j).parameters.items(): | | for (l, m) in inspect.signature(j).parameters.items(): |
| if not inspect._empty is m.annotation: | | if not inspect._empty is m.annotation: |
| try: | | try: |
n | default.append(m.annotation()) | n | lst.append(m.annotation()) |
| except: | | except: |
n | default.append(None) | n | lst.append(None) |
| if j.__defaults__ is not None: | | if j.__defaults__ is not None: |
t | length = len(j.__defaults__) | t | l = len(j.__defaults__) |
| default[-length:] = j.__defaults__ | | lst[-l:] = j.__defaults__ |
| j.__defaults__ = tuple(default) | | j.__defaults__ = tuple(lst) |
| return super().__new__(metacls, name, parents, ns) | | return super().__new__(metaclass, name, parents, ns) |