Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def annotated_func(args=[]):
  2.     for arg in args:
  3.         if not isinstance(arg, (type, TypedAny, TypedUnion, TypedList, TypedTuple,
  4.                                 TypedDict, TypedSet, TypedCallable, TypedAnnotatedCallable)):
  5.             raise TypeError
  6.  
  7.     def annotated_decor(func):
  8.         if len(args) != len(ins.signature(func).parameters):
  9.             raise TypeError
  10.         # setattr(func, '__types__', args)
  11.         func.__types__ = args
  12.         return func
  13.  
  14.     return annotated_decor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement