(self, expr: MemberExpr)
| 6121 | return True |
| 6122 | |
| 6123 | def visit_member_expr(self, expr: MemberExpr) -> None: |
| 6124 | base = expr.expr |
| 6125 | base.accept(self) |
| 6126 | if isinstance(base, RefExpr) and isinstance(base.node, MypyFile): |
| 6127 | # Handle module attribute. |
| 6128 | sym = self.get_module_symbol(base.node, expr.name) |
| 6129 | if sym: |
| 6130 | if isinstance(sym.node, PlaceholderNode): |
| 6131 | self.process_placeholder(expr.name, "attribute", expr) |
| 6132 | return |
| 6133 | self.record_imported_symbol(sym) |
| 6134 | expr.kind = sym.kind |
| 6135 | expr.fullname = sym.fullname or "" |
| 6136 | expr.node = sym.node |
| 6137 | elif isinstance(base, RefExpr): |
| 6138 | # This branch handles the case C.bar (or cls.bar or self.bar inside |
| 6139 | # a classmethod/method), where C is a class and bar is a type |
| 6140 | # definition or a module resulting from `import bar` (or a module |
| 6141 | # assignment) inside class C. We look up bar in the class' TypeInfo |
| 6142 | # namespace. This is done only when bar is a module or a type; |
| 6143 | # other things (e.g. methods) are handled by other code in |
| 6144 | # checkmember. |
| 6145 | type_info = None |
| 6146 | if isinstance(base.node, TypeInfo): |
| 6147 | # C.bar where C is a class |
| 6148 | type_info = base.node |
| 6149 | elif isinstance(base.node, Var) and self.type and self.function_stack: |
| 6150 | # check for self.bar or cls.bar in method/classmethod |
| 6151 | func_def = self.function_stack[-1] |
| 6152 | if ( |
| 6153 | func_def.has_self_or_cls_argument |
| 6154 | and func_def.info is self.type |
| 6155 | and isinstance(func_def.type, CallableType) |
| 6156 | and func_def.arguments |
| 6157 | and base.node is func_def.arguments[0].variable |
| 6158 | ): |
| 6159 | type_info = self.type |
| 6160 | elif isinstance(base.node, TypeAlias) and base.node.no_args: |
| 6161 | assert isinstance(base.node.target, ProperType) |
| 6162 | if isinstance(base.node.target, Instance): |
| 6163 | type_info = base.node.target.type |
| 6164 | |
| 6165 | if type_info: |
| 6166 | n = type_info.names.get(expr.name) |
| 6167 | if n is not None and isinstance(n.node, (MypyFile, TypeInfo, TypeAlias)): |
| 6168 | self.record_imported_symbol(n) |
| 6169 | expr.kind = n.kind |
| 6170 | expr.fullname = n.fullname or "" |
| 6171 | expr.node = n.node |
| 6172 | |
| 6173 | def visit_op_expr(self, expr: OpExpr) -> None: |
| 6174 | expr.left.accept(self) |
nothing calls this directly
no test coverage detected