Type of a non-overloaded callable object (such as function).
| 2133 | |
| 2134 | |
| 2135 | class CallableType(FunctionLike): |
| 2136 | """Type of a non-overloaded callable object (such as function).""" |
| 2137 | |
| 2138 | __slots__ = ( |
| 2139 | "arg_types", # Types of function arguments |
| 2140 | "arg_kinds", # ARG_ constants |
| 2141 | "arg_names", # Argument names; None if not a keyword argument |
| 2142 | "min_args", # Minimum number of arguments; derived from arg_kinds |
| 2143 | "ret_type", # Return value type |
| 2144 | "name", # Name (may be None; for error messages and plugins) |
| 2145 | "definition", # For error messages. May be None. |
| 2146 | "variables", # Type variables for a generic function |
| 2147 | "is_ellipsis_args", # Is this Callable[..., t] (with literal '...')? |
| 2148 | "implicit", # Was this type implicitly generated instead of explicitly |
| 2149 | # specified by the user? |
| 2150 | "special_sig", # Non-None for signatures that require special handling |
| 2151 | # (currently only values are 'dict' for a signature similar to |
| 2152 | # 'dict' and 'partial' for a `functools.partial` evaluation) |
| 2153 | "from_type_type", # Was this callable generated by analyzing Type[...] |
| 2154 | # instantiation? |
| 2155 | "is_bound", # Is this a bound method? |
| 2156 | "type_guard", # T, if -> TypeGuard[T] (ret_type is bool in this case). |
| 2157 | "type_is", # T, if -> TypeIs[T] (ret_type is bool in this case). |
| 2158 | "from_concatenate", # whether this callable is from a concatenate object |
| 2159 | # (this is used for error messages) |
| 2160 | "imprecise_arg_kinds", |
| 2161 | "unpack_kwargs", # Was an Unpack[...] with **kwargs used to define this callable? |
| 2162 | ) |
| 2163 | |
| 2164 | def __init__( |
| 2165 | self, |
| 2166 | # maybe this should be refactored to take a Parameters object |
| 2167 | arg_types: Sequence[Type], |
| 2168 | arg_kinds: list[ArgKind], |
| 2169 | arg_names: Sequence[str | None], |
| 2170 | ret_type: Type, |
| 2171 | fallback: Instance, |
| 2172 | name: str | None = None, |
| 2173 | definition: SymbolNode | None = None, |
| 2174 | variables: Sequence[TypeVarLikeType] | None = None, |
| 2175 | line: int = -1, |
| 2176 | column: int = -1, |
| 2177 | is_ellipsis_args: bool = False, |
| 2178 | implicit: bool = False, |
| 2179 | special_sig: str | None = None, |
| 2180 | from_type_type: bool = False, |
| 2181 | is_bound: bool = False, |
| 2182 | type_guard: Type | None = None, |
| 2183 | type_is: Type | None = None, |
| 2184 | from_concatenate: bool = False, |
| 2185 | imprecise_arg_kinds: bool = False, |
| 2186 | unpack_kwargs: bool = False, |
| 2187 | ) -> None: |
| 2188 | super().__init__(line, column) |
| 2189 | assert len(arg_types) == len(arg_kinds) == len(arg_names) |
| 2190 | self.arg_types = list(arg_types) |
| 2191 | for t in self.arg_types: |
| 2192 | if isinstance(t, ParamSpecType): |
no outgoing calls
searching dependent graphs…