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