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

Function format_union_items

mypy/messages.py:2669–2680  ·  view source on GitHub ↗
(types: Sequence[Type])

Source from the content-addressed store, hash-verified

2667 return ", ".join(format(typ) for typ in types)
2668
2669 def format_union_items(types: Sequence[Type]) -> list[str]:
2670 formatted = [format(typ) for typ in types if format(typ) != "None"]
2671 if len(formatted) > MAX_UNION_ITEMS and verbosity == 0:
2672 more = len(formatted) - MAX_UNION_ITEMS // 2
2673 formatted = formatted[: MAX_UNION_ITEMS // 2]
2674 else:
2675 more = 0
2676 if more:
2677 formatted.append(f"<{more} more items>")
2678 if any(format(typ) == "None" for typ in types):
2679 formatted.append("None")
2680 return formatted
2681
2682 def format_union(types: Sequence[Type]) -> str:
2683 return " | ".join(format_union_items(types))

Callers 1

format_unionFunction · 0.85

Calls 4

formatFunction · 0.85
lenFunction · 0.85
anyFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…