| 243 | class FunctionSignature: |
| 244 | |
| 245 | def __init__(self, function: Callable) -> None: |
| 246 | import inspect |
| 247 | |
| 248 | sfn = inspect.signature(function) |
| 249 | self.found_args = False |
| 250 | self.found_kwargs = False |
| 251 | self.defaults = {} |
| 252 | self.non_var_parameters = set() |
| 253 | for p in sfn.parameters.values(): |
| 254 | if p.kind is inspect.Parameter.VAR_POSITIONAL: |
| 255 | self.found_args = True |
| 256 | if p.kind is inspect.Parameter.VAR_KEYWORD: |
| 257 | self.found_kwargs = True |
| 258 | else: |
| 259 | self.non_var_parameters.add(p.name) |
| 260 | self.defaults[p.name] = p.default is not p.empty |
| 261 | |
| 262 | def __repr__(self) -> str: |
| 263 | s = "<class 'FunctionSignature': found_args={}, found_kwargs={}, defaults={}" |