Skip to content

Mention common resolutions for build errors #12154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,15 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
)
manager.errors.report(
-1, -1,
"Are you missing an __init__.py? Alternatively, consider using --exclude to "
"avoid checking one of them.",
"See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules " # noqa: E501
"for more info",
severity='note',
)
manager.errors.report(
-1, -1,
"Common resolutions include: a) using `--exclude` to avoid checking one of them, "
"b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or "
"adjusting MYPYPATH",
severity='note'
)

Expand Down Expand Up @@ -2905,6 +2912,12 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
"for more info",
severity='note',
)
manager.errors.report(
-1, 0,
"Common resolutions include: a) adding `__init__.py` somewhere, "
"b) using `--explicit-package-bases` or adjusting MYPYPATH",
severity='note',
)
manager.errors.raise_error()

seen_files[newst_path] = newst
Expand Down
7 changes: 5 additions & 2 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ undef
undef
[out]
dir/a.py: error: Duplicate module named "a" (also at "dir/subdir/a.py")
dir/a.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them.
dir/a.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
dir/a.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
== Return code: 2

[case testCmdlineNonPackageSlash]
Expand Down Expand Up @@ -125,7 +126,8 @@ mypy: can't decode file 'a.py': unknown encoding: uft-8
# type: ignore
[out]
two/mod/__init__.py: error: Duplicate module named "mod" (also at "one/mod/__init__.py")
two/mod/__init__.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them.
two/mod/__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
two/mod/__init__.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
== Return code: 2

[case testFlagsFile]
Expand Down Expand Up @@ -1144,6 +1146,7 @@ import foo.bar
[out]
src/foo/bar.py: error: Source file found twice under different module names: "src.foo.bar" and "foo.bar"
src/foo/bar.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
src/foo/bar.py: note: Common resolutions include: a) adding `__init__.py` somewhere, b) using `--explicit-package-bases` or adjusting MYPYPATH
== Return code: 2

[case testEnableInvalidErrorCode]
Expand Down