Skip to content

Commit

Permalink
Query both relative and absolute path in module duplication check
Browse files Browse the repository at this point in the history
  • Loading branch information
bonprosoft authored and msullivan committed Oct 18, 2020
1 parent 4397783 commit ad54c7f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,7 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,

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

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

if newst_path in seen_files:
if seen_state is None:
if os.path.isabs(newst_path):
newst_path = os.path.relpath(newst_path)
else:
newst_path = os.path.abspath(newst_path)

seen_state = seen_files.get(newst_path)

if seen_state is not None:
manager.errors.report(
-1, 0,
"Source file found twice under different module names: "
"'{}' and '{}'".format(seen_files[newst_path].id, newst.id),
"'{}' and '{}'".format(seen_state.id, newst.id),
blocker=True)
manager.errors.raise_error()

seen_files[newst_path] = newst
seen_files[newst.path] = newst

assert newst.id not in graph, newst.id
graph[newst.id] = newst
Expand Down

0 comments on commit ad54c7f

Please sign in to comment.