MCPcopy Index your code
hub / github.com/python/cpython / __mro_entries__

Method __mro_entries__

Lib/typing.py:1294–1324  ·  view source on GitHub ↗
(self, bases)

Source from the content-addressed store, hash-verified

1292 return result
1293
1294 def __mro_entries__(self, bases):
1295 res = []
1296 if self.__origin__ not in bases:
1297 res.append(self.__origin__)
1298
1299 # Check if any base that occurs after us in `bases` is either itself a
1300 # subclass of Generic, or something which will add a subclass of Generic
1301 # to `__bases__` via its `__mro_entries__`. If not, add Generic
1302 # ourselves. The goal is to ensure that Generic (or a subclass) will
1303 # appear exactly once in the final bases tuple. If we let it appear
1304 # multiple times, we risk "can't form a consistent MRO" errors.
1305 i = bases.index(self)
1306 for b in bases[i+1:]:
1307 if isinstance(b, _BaseGenericAlias):
1308 break
1309 if not isinstance(b, type):
1310 meth = getattr(b, "__mro_entries__", None)
1311 new_bases = meth(bases) if meth else None
1312 if (
1313 isinstance(new_bases, tuple) and
1314 any(
1315 isinstance(b2, type) and issubclass(b2, Generic)
1316 for b2 in new_bases
1317 )
1318 ):
1319 break
1320 elif issubclass(b, Generic):
1321 break
1322 else:
1323 res.append(Generic)
1324 return tuple(res)
1325
1326 def __getattr__(self, attr):
1327 if attr in {'__name__', '__qualname__'}:

Callers

nothing calls this directly

Calls 4

methFunction · 0.85
anyFunction · 0.70
appendMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected