(node, sig)
| 437 | |
| 438 | |
| 439 | def update_sig_from_node(node, sig): |
| 440 | params = dict(sig.parameters) |
| 441 | args = node.args |
| 442 | allargs = ( |
| 443 | *args.posonlyargs, |
| 444 | *args.args, |
| 445 | args.vararg, |
| 446 | *args.kwonlyargs, |
| 447 | args.kwarg, |
| 448 | ) |
| 449 | for param in allargs: |
| 450 | if param is None: |
| 451 | continue |
| 452 | if param.annotation is None: |
| 453 | continue |
| 454 | annotation = direct_repr(ast.unparse(param.annotation)) |
| 455 | params[param.arg] = params[param.arg].replace(annotation=annotation) |
| 456 | |
| 457 | if node.returns is not None: |
| 458 | return inspect.Signature( |
| 459 | params.values(), |
| 460 | return_annotation=direct_repr(ast.unparse(node.returns)) |
| 461 | ) |
| 462 | else: |
| 463 | return inspect.Signature(params.values()) |
| 464 | |
| 465 | |
| 466 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…