(self, node: MypyFile)
| 463 | return AnyType(TypeOfAny.special_form) |
| 464 | |
| 465 | def module_type(self, node: MypyFile) -> Instance: |
| 466 | try: |
| 467 | result = self.named_type("types.ModuleType") |
| 468 | except KeyError: |
| 469 | # In test cases might 'types' may not be available. |
| 470 | # Fall back to a dummy 'object' type instead to |
| 471 | # avoid a crash. |
| 472 | # Make a copy so that we don't set extra_attrs (below) on a shared instance. |
| 473 | result = self.named_type("builtins.object").copy_modified() |
| 474 | module_attrs: dict[str, Type] = {} |
| 475 | immutable = set() |
| 476 | for name, n in node.names.items(): |
| 477 | if not n.module_public: |
| 478 | continue |
| 479 | if isinstance(n.node, Var) and n.node.is_final: |
| 480 | immutable.add(name) |
| 481 | if n.node is None: |
| 482 | module_attrs[name] = AnyType(TypeOfAny.from_error) |
| 483 | else: |
| 484 | # TODO: what to do about nested module references? |
| 485 | # They are non-trivial because there may be import cycles. |
| 486 | module_attrs[name] = self.analyze_static_reference( |
| 487 | n.node, n.node, False, include_modules=False, suppress_errors=True |
| 488 | ) |
| 489 | result.extra_attrs = ExtraAttrs(module_attrs, immutable, node.fullname) |
| 490 | return result |
| 491 | |
| 492 | def visit_call_expr(self, e: CallExpr, allow_none_return: bool = False) -> Type: |
| 493 | """Type check a call expression.""" |
no test coverage detected