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

Function get_bad_protocol_flags

mypy/messages.py:3236–3272  ·  view source on GitHub ↗

Return all incompatible attribute flags for members that are present in both 'left' and 'right'.

(
    left: Instance, right: Instance, class_obj: bool = False
)

Source from the content-addressed store, hash-verified

3234
3235
3236def get_bad_protocol_flags(
3237 left: Instance, right: Instance, class_obj: bool = False
3238) -> list[tuple[str, set[int], set[int]]]:
3239 """Return all incompatible attribute flags for members that are present in both
3240 'left' and 'right'.
3241 """
3242 assert right.type.is_protocol
3243 all_flags: list[tuple[str, set[int], set[int]]] = []
3244 for member in right.type.protocol_members:
3245 if find_member(member, left, left, class_obj=class_obj):
3246 all_flags.append(
3247 (
3248 member,
3249 get_member_flags(member, left, class_obj=class_obj),
3250 get_member_flags(member, right),
3251 )
3252 )
3253 bad_flags = []
3254 for name, subflags, superflags in all_flags:
3255 if (
3256 IS_CLASSVAR in subflags
3257 and IS_CLASSVAR not in superflags
3258 and IS_SETTABLE in superflags
3259 or IS_CLASSVAR in superflags
3260 and IS_CLASSVAR not in subflags
3261 or IS_SETTABLE in superflags
3262 and IS_SETTABLE not in subflags
3263 or IS_CLASS_OR_STATIC in superflags
3264 and IS_CLASS_OR_STATIC not in subflags
3265 or class_obj
3266 and IS_VAR in superflags
3267 and IS_CLASSVAR not in subflags
3268 or class_obj
3269 and IS_CLASSVAR in superflags
3270 ):
3271 bad_flags.append((name, subflags, superflags))
3272 return bad_flags
3273
3274
3275def capitalize(s: str) -> str:

Callers 1

Calls 3

find_memberFunction · 0.90
get_member_flagsFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…