MCPcopy Create free account
hub / github.com/python/mypy / group_consecutive

Function group_consecutive

mypyc/irbuild/statement.py:485–501  ·  view source on GitHub ↗

Group consecutive items by kind (first element) into ImportFromBuckets. Each item is a (kind, name, as_name) tuple.

(items: list[tuple[int, str, str]])

Source from the content-addressed store, hash-verified

483
484
485def group_consecutive(items: list[tuple[int, str, str]]) -> list[ImportFromBucket]:
486 """Group consecutive items by kind (first element) into ImportFromBuckets.
487
488 Each item is a (kind, name, as_name) tuple.
489 """
490 result: list[ImportFromBucket] = []
491 i = 0
492 while i < len(items):
493 kind = items[i][0]
494 i0 = i
495 i += 1
496 while i < len(items) and items[i][0] == kind:
497 i += 1
498 result.append(
499 ImportFromBucket(kind, [t[1] for t in items[i0:i]], [t[2] for t in items[i0:i]])
500 )
501 return result
502
503
504def classify_import_from(

Calls 3

lenFunction · 0.85
ImportFromBucketClass · 0.85
appendMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…