(func: FuncBase, fallback: Instance)
| 863 | |
| 864 | |
| 865 | def function_type(func: FuncBase, fallback: Instance) -> FunctionLike: |
| 866 | if func.type: |
| 867 | assert isinstance(func.type, FunctionLike) |
| 868 | return func.type |
| 869 | else: |
| 870 | # Implicit type signature with dynamic types. |
| 871 | if isinstance(func, FuncItem): |
| 872 | return callable_type(func, fallback) |
| 873 | else: |
| 874 | # Either a broken overload, or decorated overload type is not ready. |
| 875 | # TODO: make sure the caller defers if possible. |
| 876 | assert isinstance(func, OverloadedFuncDef) |
| 877 | any_type = AnyType(TypeOfAny.from_error) |
| 878 | dummy = CallableType( |
| 879 | [any_type, any_type], |
| 880 | [ARG_STAR, ARG_STAR2], |
| 881 | [None, None], |
| 882 | any_type, |
| 883 | fallback, |
| 884 | line=func.line, |
| 885 | is_ellipsis_args=True, |
| 886 | ) |
| 887 | # Return an Overloaded, because some callers may expect that |
| 888 | # an OverloadedFuncDef has an Overloaded type. |
| 889 | return Overloaded([dummy]) |
| 890 | |
| 891 | |
| 892 | def callable_type( |
no test coverage detected
searching dependent graphs…