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

Function has_bytes_component

mypy/checkexpr.py:6935–6943  ·  view source on GitHub ↗

Is this one of builtin byte types, or a union that contains it?

(typ: Type)

Source from the content-addressed store, hash-verified

6933
6934
6935def has_bytes_component(typ: Type) -> bool:
6936 """Is this one of builtin byte types, or a union that contains it?"""
6937 typ = get_proper_type(typ)
6938 byte_types = {"builtins.bytes", "builtins.bytearray"}
6939 if isinstance(typ, UnionType):
6940 return any(has_bytes_component(t) for t in typ.items)
6941 if isinstance(typ, Instance) and typ.type.fullname in byte_types:
6942 return True
6943 return False
6944
6945
6946def type_info_from_type(typ: Type) -> TypeInfo | None:

Callers 1

dangerous_comparisonMethod · 0.85

Calls 3

get_proper_typeFunction · 0.90
isinstanceFunction · 0.85
anyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…