Skip to content

Commit c1f7d1e

Browse files
committed
Query both relative and absolute path in module duplication check
1 parent d9c5c65 commit c1f7d1e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

mypy/build.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
27542754

27552755
# Note: Running this each time could be slow in the daemon. If it's a problem, we
27562756
# can do more work to maintain this incrementally.
2757-
seen_files = {os.path.abspath(st.path): st for st in graph.values() if st.path}
2757+
seen_files = {st.path: st for st in graph.values() if st.path}
27582758

27592759
# Collect dependencies. We go breadth-first.
27602760
# More nodes might get added to new as we go, but that's fine.
@@ -2802,17 +2802,26 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
28022802
st.suppress_dependency(dep)
28032803
else:
28042804
if newst.path:
2805-
newst_path = os.path.abspath(newst.path)
2805+
newst_path = newst.path
2806+
seen_state = seen_files.get(newst_path)
28062807

2807-
if newst_path in seen_files:
2808+
if seen_state is None:
2809+
if os.path.isabs(newst_path):
2810+
newst_path = os.path.relpath(newst_path)
2811+
else:
2812+
newst_path = os.path.abspath(newst_path)
2813+
2814+
seen_state = seen_files.get(newst_path)
2815+
2816+
if seen_state is not None:
28082817
manager.errors.report(
28092818
-1, 0,
28102819
"Source file found twice under different module names: "
2811-
"'{}' and '{}'".format(seen_files[newst_path].id, newst.id),
2820+
"'{}' and '{}'".format(seen_state.id, newst.id),
28122821
blocker=True)
28132822
manager.errors.raise_error()
28142823

2815-
seen_files[newst_path] = newst
2824+
seen_files[newst.path] = newst
28162825

28172826
assert newst.id not in graph, newst.id
28182827
graph[newst.id] = newst

0 commit comments

Comments
 (0)