Skip to content

Commit 0d61315

Browse files
authored
stubtest: use single line error message (#13301)
This preserves the invariant that in `--concise` the problematic objects are the start of each line. It also matches the pattern we have for e.g. the "explicitly passing in defaults" error message. Also add some comments.
1 parent f6bac71 commit 0d61315

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

mypy/stubtest.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ def verify(
246246
def _verify_exported_names(
247247
object_path: List[str], stub: nodes.MypyFile, runtime_all_as_set: Set[str]
248248
) -> Iterator[Error]:
249+
# note that this includes the case the stub simply defines `__all__: list[str]`
250+
assert "__all__" in stub.names
249251
public_names_in_stub = {m for m, o in stub.names.items() if o.module_public}
250252
names_in_stub_not_runtime = sorted(public_names_in_stub - runtime_all_as_set)
251253
names_in_runtime_not_stub = sorted(runtime_all_as_set - public_names_in_stub)
@@ -254,16 +256,13 @@ def _verify_exported_names(
254256
yield Error(
255257
object_path,
256258
(
257-
"module: names exported from the stub "
258-
"do not correspond to the names exported at runtime.\n"
259-
"(Note: This is probably either due to an inaccurate "
260-
"`__all__` in the stub, "
261-
"or due to a name being declared in `__all__` "
262-
"but not actually defined in the stub.)"
259+
"names exported from the stub do not correspond to the names exported at runtime. "
260+
"This is probably due to an inaccurate `__all__` in the stub or things being missing from the stub."
263261
),
264-
# pass in MISSING instead of the stub and runtime objects,
265-
# as the line numbers aren't very relevant here,
266-
# and it makes for a prettier error message.
262+
# Pass in MISSING instead of the stub and runtime objects, as the line numbers aren't very
263+
# relevant here, and it makes for a prettier error message
264+
# This means this error will be ignored when using `--ignore-missing-stub`, which is
265+
# desirable in at least the `names_in_runtime_not_stub` case
267266
stub_object=MISSING,
268267
runtime_object=MISSING,
269268
stub_desc=(

0 commit comments

Comments
 (0)