From d2fd65dd014b357884225e021adf59cf5dfd987c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 29 Nov 2022 11:57:30 +0300 Subject: [PATCH 1/3] [stubtest] Error related to `__all__` must have it in the error path --- mypy/stubtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 8add8178823aa..4e846c01da693 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -261,7 +261,7 @@ def _verify_exported_names( if not (names_in_runtime_not_stub or names_in_stub_not_runtime): return yield Error( - object_path, + object_path + ["__all__"], ( "names exported from the stub do not correspond to the names exported at runtime. " "This is probably due to an inaccurate `__all__` in the stub or things being missing from the stub." From 5a8efde78678d4d958de0cf94da36c1b7b3d5503 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 29 Nov 2022 12:47:26 +0300 Subject: [PATCH 2/3] Fix tests --- mypy/test/teststubtest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index e863f4f575688..812333e3feb49 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -1028,7 +1028,7 @@ def test_all_in_stub_not_at_runtime(self) -> Iterator[Case]: @collect_cases def test_all_in_stub_different_to_all_at_runtime(self) -> Iterator[Case]: - # We *should* emit an error with the module name itself, + # We *should* emit an error with the module name itself + __all__, # if the stub *does* define __all__, # but the stub's __all__ is inconsistent with the runtime's __all__ yield Case( @@ -1040,7 +1040,7 @@ def test_all_in_stub_different_to_all_at_runtime(self) -> Iterator[Case]: __all__ = [] foo = 'foo' """, - error="", + error="__all__", ) @collect_cases From c297cc6370d7c432f58d6f37cfd1a3325a7afb15 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 30 Nov 2022 02:25:55 +0300 Subject: [PATCH 3/3] Update mypy/stubtest.py Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- mypy/stubtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 4e846c01da693..0fcabadeb074c 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -264,7 +264,7 @@ def _verify_exported_names( object_path + ["__all__"], ( "names exported from the stub do not correspond to the names exported at runtime. " - "This is probably due to an inaccurate `__all__` in the stub or things being missing from the stub." + "This is probably due to things being missing from the stub, or if present, an inaccurate `__all__` in the stub" ), # Pass in MISSING instead of the stub and runtime objects, as the line numbers aren't very # relevant here, and it makes for a prettier error message