(
fdef: FuncItem, fallback: Instance, ret_type: Type | None = None
)
| 890 | |
| 891 | |
| 892 | def callable_type( |
| 893 | fdef: FuncItem, fallback: Instance, ret_type: Type | None = None |
| 894 | ) -> CallableType: |
| 895 | # TODO: somewhat unfortunate duplication with prepare_method_signature in semanal |
| 896 | if fdef.info and fdef.has_self_or_cls_argument and fdef.arg_names: |
| 897 | self_type: Type = fill_typevars(fdef.info) |
| 898 | if fdef.is_class or fdef.name == "__new__": |
| 899 | self_type = TypeType.make_normalized(self_type) |
| 900 | args = [self_type] + [AnyType(TypeOfAny.unannotated)] * (len(fdef.arg_names) - 1) |
| 901 | else: |
| 902 | args = [AnyType(TypeOfAny.unannotated)] * len(fdef.arg_names) |
| 903 | |
| 904 | return CallableType( |
| 905 | args, |
| 906 | fdef.arg_kinds, |
| 907 | fdef.arg_names, |
| 908 | ret_type or AnyType(TypeOfAny.unannotated), |
| 909 | fallback, |
| 910 | name=fdef.name, |
| 911 | line=fdef.line, |
| 912 | column=fdef.column, |
| 913 | implicit=True, |
| 914 | # We need this for better error messages, like missing `self` note: |
| 915 | definition=fdef if isinstance(fdef, FuncDef) else None, |
| 916 | ) |
| 917 | |
| 918 | |
| 919 | def try_getting_str_literals(expr: Expression, typ: Type) -> list[str] | None: |
no test coverage detected
searching dependent graphs…