MCPcopy Index your code
hub / github.com/python/mypy / may_be_awaitable_attribute

Function may_be_awaitable_attribute

mypy/checkmember.py:284–298  ·  view source on GitHub ↗

Check if the given type has the attribute when awaited.

(
    name: str, typ: Type, mx: MemberContext, override_info: TypeInfo | None = None
)

Source from the content-addressed store, hash-verified

282
283
284def may_be_awaitable_attribute(
285 name: str, typ: Type, mx: MemberContext, override_info: TypeInfo | None = None
286) -> bool:
287 """Check if the given type has the attribute when awaited."""
288 if mx.chk.checking_missing_await:
289 # Avoid infinite recursion.
290 return False
291 with mx.chk.checking_await_set(), mx.msg.filter_errors() as local_errors:
292 aw_type = mx.chk.get_precise_awaitable_type(typ, local_errors)
293 if aw_type is None:
294 return False
295 _ = _analyze_member_access(
296 name, aw_type, mx.copy_modified(self_type=aw_type), override_info
297 )
298 return not local_errors.has_new_errors()
299
300
301def report_missing_attribute(

Callers 1

report_missing_attributeFunction · 0.85

Calls 6

_analyze_member_accessFunction · 0.85
filter_errorsMethod · 0.80
has_new_errorsMethod · 0.80
checking_await_setMethod · 0.45
copy_modifiedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…