(self, e: ListExpr | SetExpr | TupleExpr, fullname: str, tag: str)
| 5223 | return typ |
| 5224 | |
| 5225 | def check_lst_expr(self, e: ListExpr | SetExpr | TupleExpr, fullname: str, tag: str) -> Type: |
| 5226 | # fast path |
| 5227 | t = self.fast_container_type(e, fullname) |
| 5228 | if t: |
| 5229 | return t |
| 5230 | |
| 5231 | # Translate into type checking a generic function call. |
| 5232 | # Used for list and set expressions, as well as for tuples |
| 5233 | # containing star expressions that don't refer to a |
| 5234 | # Tuple. (Note: "lst" stands for list-set-tuple. :-) |
| 5235 | tv = TypeVarType( |
| 5236 | "T", |
| 5237 | "T", |
| 5238 | id=TypeVarId(-1, namespace="<lst>"), |
| 5239 | values=[], |
| 5240 | upper_bound=self.object_type(), |
| 5241 | default=AnyType(TypeOfAny.from_omitted_generics), |
| 5242 | ) |
| 5243 | constructor = CallableType( |
| 5244 | [tv], |
| 5245 | [nodes.ARG_STAR], |
| 5246 | [None], |
| 5247 | self.chk.named_generic_type(fullname, [tv]), |
| 5248 | self.named_type("builtins.function"), |
| 5249 | name=tag, |
| 5250 | variables=[tv], |
| 5251 | ) |
| 5252 | out = self.check_call( |
| 5253 | constructor, |
| 5254 | [(i.expr if isinstance(i, StarExpr) else i) for i in e.items], |
| 5255 | [(nodes.ARG_STAR if isinstance(i, StarExpr) else nodes.ARG_POS) for i in e.items], |
| 5256 | e, |
| 5257 | )[0] |
| 5258 | return remove_instance_last_known_values(out) |
| 5259 | |
| 5260 | def tuple_context_matches(self, expr: TupleExpr, ctx: TupleType) -> bool: |
| 5261 | ctx_unpack_index = find_unpack_in_list(ctx.items) |
no test coverage detected