in usort/sorting.py [0:0]
def name_overlap(self, block: SortableBlock, imp: SortableImport) -> Set[str]:
"""
Find imported names that overlap existing names for a block of imports.
Compares imports of a proposed, but not yet included, import with existing imports
in a block. Ignores multiple imports of the same "name" that come from the same
qualified name. Eg, `os.path` doesn't shadow `os`, but `from foo import os` does.
Returns a set of qualified names from `imp` that shadow names from `block`.
This set will be empty if there are no overlaps.
"""
overlap: Set[str] = set()
for key, value in imp.imported_names.items():
shadowed = block.imported_names.get(key)
if shadowed and shadowed != value:
self.warning_nodes.append(
(
imp.node,
f"Name {shadowed!r} shadowed by {value!r}; "
"implicit block split",
)
)
overlap.add(shadowed)
return overlap