Return the expression for the specific argument.
(call: CallExpr, name: str)
| 74 | |
| 75 | |
| 76 | def _get_argument(call: CallExpr, name: str) -> Expression | None: |
| 77 | """Return the expression for the specific argument.""" |
| 78 | # To do this we use the CallableType of the callee to find the FormalArgument, |
| 79 | # then walk the actual CallExpr looking for the appropriate argument. |
| 80 | # |
| 81 | # Note: I'm not hard-coding the index so that in the future we can support other |
| 82 | # attrib and class makers. |
| 83 | callee_type = _get_callee_type(call) |
| 84 | if not callee_type: |
| 85 | return None |
| 86 | |
| 87 | argument = callee_type.argument_by_name(name) |
| 88 | if not argument: |
| 89 | return None |
| 90 | assert argument.name |
| 91 | |
| 92 | for i, (attr_name, attr_value) in enumerate(zip(call.arg_names, call.args)): |
| 93 | if argument.pos is not None and not attr_name and i == argument.pos: |
| 94 | return attr_value |
| 95 | if attr_name == argument.name: |
| 96 | return attr_value |
| 97 | |
| 98 | return None |
| 99 | |
| 100 | |
| 101 | def find_shallow_matching_overload_item(overload: Overloaded, call: CallExpr) -> CallableType: |
no test coverage detected
searching dependent graphs…