Constructor for instantiating from values. The return types of the exprs will be inspected and used to find the function signature. If no signature can be found an error will be raised.
(cls, *val_exprs)
| 143 | |
| 144 | @classmethod |
| 145 | def create_from_args(cls, *val_exprs): |
| 146 | '''Constructor for instantiating from values. The return types of the exprs will be |
| 147 | inspected and used to find the function signature. If no signature can be found |
| 148 | an error will be raised. |
| 149 | ''' |
| 150 | for signature in cls.signatures(): |
| 151 | if len(signature.args) != len(val_exprs): |
| 152 | continue |
| 153 | for idx, arg in enumerate(val_exprs): |
| 154 | if not issubclass(arg.type, signature.args[idx].type): |
| 155 | break |
| 156 | else: |
| 157 | break |
| 158 | else: |
| 159 | raise Exception('No signature matches the given arguments: %s' % (val_exprs, )) |
| 160 | return cls(signature, *val_exprs) |
| 161 | |
| 162 | def __init__(self, signature, *val_exprs): |
| 163 | '''"signature" should be one of the available signatures at the class level and |