Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f210d6c

Browse files
jxclGuido van Rossum
authored andcommitted
Display both instances of duplicate modules in error message (#6772)
Fixes #6741
1 parent 9f823a7 commit f210d6c

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

mypy/build.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,10 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
25692569
continue
25702570
if st.id in graph:
25712571
manager.errors.set_file(st.xpath, st.id)
2572-
manager.errors.report(-1, -1, "Duplicate module named '%s'" % st.id)
2572+
manager.errors.report(
2573+
-1, -1,
2574+
"Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath)
2575+
)
25732576
manager.errors.raise_error()
25742577
graph[st.id] = st
25752578
new.append(st)

test-data/unit/cmdline.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mypy: can't decode file 'a.py': unknown encoding: uft-8
106106
[file two/mod/__init__.py]
107107
# type: ignore
108108
[out]
109-
two/mod/__init__.py: error: Duplicate module named 'mod'
109+
two/mod/__init__.py: error: Duplicate module named 'mod' (also at 'one/mod/__init__.py')
110110
== Return code: 2
111111

112112
[case testFlagsFile]

0 commit comments

Comments
 (0)