|
19 | 19 | ARG_STAR, |
20 | 20 | EXCLUDED_ENUM_ATTRIBUTES, |
21 | 21 | SYMBOL_FUNCBASE_TYPES, |
22 | | - ArgKind, |
23 | 22 | Context, |
24 | 23 | Decorator, |
25 | 24 | FuncBase, |
@@ -1094,7 +1093,7 @@ def analyze_class_attribute_access( |
1094 | 1093 | if isinstance(node.node, TypeInfo): |
1095 | 1094 | if node.node.typeddict_type: |
1096 | 1095 | # We special-case TypedDict, because they don't define any constructor. |
1097 | | - return typeddict_callable(node.node, mx.named_type) |
| 1096 | + return mx.chk.expr_checker.typeddict_callable(node.node) |
1098 | 1097 | elif node.node.fullname == "types.NoneType": |
1099 | 1098 | # We special case NoneType, because its stub definition is not related to None. |
1100 | 1099 | return TypeType(NoneType()) |
@@ -1280,31 +1279,6 @@ class B(A[str]): pass |
1280 | 1279 | return t |
1281 | 1280 |
|
1282 | 1281 |
|
1283 | | -def typeddict_callable(info: TypeInfo, named_type: Callable[[str], Instance]) -> CallableType: |
1284 | | - """Construct a reasonable type for a TypedDict type in runtime context. |
1285 | | -
|
1286 | | - If it appears as a callee, it will be special-cased anyway, e.g. it is |
1287 | | - also allowed to accept a single positional argument if it is a dict literal. |
1288 | | -
|
1289 | | - Note it is not safe to move this to type_object_type() since it will crash |
1290 | | - on plugin-generated TypedDicts, that may not have the special_alias. |
1291 | | - """ |
1292 | | - assert info.special_alias is not None |
1293 | | - target = info.special_alias.target |
1294 | | - assert isinstance(target, ProperType) and isinstance(target, TypedDictType) |
1295 | | - expected_types = list(target.items.values()) |
1296 | | - kinds = [ArgKind.ARG_NAMED] * len(expected_types) |
1297 | | - names = list(target.items.keys()) |
1298 | | - return CallableType( |
1299 | | - expected_types, |
1300 | | - kinds, |
1301 | | - names, |
1302 | | - target, |
1303 | | - named_type("builtins.type"), |
1304 | | - variables=info.defn.type_vars, |
1305 | | - ) |
1306 | | - |
1307 | | - |
1308 | 1282 | def analyze_decorator_or_funcbase_access( |
1309 | 1283 | defn: Decorator | FuncBase, itype: Instance, name: str, mx: MemberContext |
1310 | 1284 | ) -> Type: |
|
0 commit comments