(
name: str, typ: Type, mx: MemberContext, override_info: TypeInfo | None = None
)
| 240 | |
| 241 | |
| 242 | def _analyze_member_access( |
| 243 | name: str, typ: Type, mx: MemberContext, override_info: TypeInfo | None = None |
| 244 | ) -> Type: |
| 245 | typ = get_proper_type(typ) |
| 246 | if isinstance(typ, Instance): |
| 247 | return analyze_instance_member_access(name, typ, mx, override_info) |
| 248 | elif isinstance(typ, AnyType): |
| 249 | # The base object has dynamic type. |
| 250 | return AnyType(TypeOfAny.from_another_any, source_any=typ) |
| 251 | elif isinstance(typ, UnionType): |
| 252 | return analyze_union_member_access(name, typ, mx) |
| 253 | elif isinstance(typ, FunctionLike) and typ.is_type_obj(): |
| 254 | return analyze_type_callable_member_access(name, typ, mx) |
| 255 | elif isinstance(typ, TypeType): |
| 256 | return analyze_type_type_member_access(name, typ, mx, override_info) |
| 257 | elif isinstance(typ, TupleType): |
| 258 | # Actually look up from the fallback instance type. |
| 259 | return _analyze_member_access(name, tuple_fallback(typ), mx, override_info) |
| 260 | elif isinstance(typ, (LiteralType, FunctionLike)): |
| 261 | # Actually look up from the fallback instance type. |
| 262 | return _analyze_member_access(name, typ.fallback, mx, override_info) |
| 263 | elif isinstance(typ, TypedDictType): |
| 264 | return analyze_typeddict_access(name, typ, mx, override_info) |
| 265 | elif isinstance(typ, NoneType): |
| 266 | return analyze_none_member_access(name, typ, mx) |
| 267 | elif isinstance(typ, TypeVarLikeType): |
| 268 | if isinstance(typ, TypeVarType) and typ.values: |
| 269 | return _analyze_member_access( |
| 270 | name, make_simplified_union(typ.values), mx, override_info |
| 271 | ) |
| 272 | return _analyze_member_access(name, typ.upper_bound, mx, override_info) |
| 273 | elif isinstance(typ, DeletedType): |
| 274 | if not mx.suppress_errors: |
| 275 | mx.msg.deleted_as_rvalue(typ, mx.context) |
| 276 | return AnyType(TypeOfAny.from_error) |
| 277 | elif isinstance(typ, UninhabitedType): |
| 278 | attr_type = UninhabitedType() |
| 279 | attr_type.ambiguous = typ.ambiguous |
| 280 | return attr_type |
| 281 | return report_missing_attribute(mx.original_type, typ, name, mx) |
| 282 | |
| 283 | |
| 284 | def may_be_awaitable_attribute( |
no test coverage detected
searching dependent graphs…