Produces a list of argument names compatible with both callables. For example, suppose 't' and 's' have the following signatures: - t: (a: int, b: str, X: str) -> None - s: (a: int, b: str, Y: str) -> None This function would return ["a", "b", None]. This information is then u
(
t: CallableType | Parameters, s: CallableType | Parameters
)
| 837 | |
| 838 | |
| 839 | def combine_arg_names( |
| 840 | t: CallableType | Parameters, s: CallableType | Parameters |
| 841 | ) -> list[str | None]: |
| 842 | """Produces a list of argument names compatible with both callables. |
| 843 | |
| 844 | For example, suppose 't' and 's' have the following signatures: |
| 845 | |
| 846 | - t: (a: int, b: str, X: str) -> None |
| 847 | - s: (a: int, b: str, Y: str) -> None |
| 848 | |
| 849 | This function would return ["a", "b", None]. This information |
| 850 | is then used above to compute the join of t and s, which results |
| 851 | in a signature of (a: int, b: str, str) -> None. |
| 852 | |
| 853 | Note that the third argument's name is omitted and 't' and 's' |
| 854 | are both valid subtypes of this inferred signature. |
| 855 | |
| 856 | Precondition: is_similar_types(t, s) is true. |
| 857 | """ |
| 858 | num_args = len(t.arg_types) |
| 859 | new_names = [] |
| 860 | for i in range(num_args): |
| 861 | t_name = t.arg_names[i] |
| 862 | s_name = s.arg_names[i] |
| 863 | if t_name == s_name or t.arg_kinds[i].is_named() or s.arg_kinds[i].is_named(): |
| 864 | new_names.append(t_name) |
| 865 | else: |
| 866 | new_names.append(None) |
| 867 | return new_names |
| 868 | |
| 869 | |
| 870 | def object_from_instance(instance: Instance) -> Instance: |
no test coverage detected
searching dependent graphs…