MCPcopy
hub / github.com/python/mypy / _verify_exported_names

Function _verify_exported_names

mypy/stubtest.py:301–327  ·  view source on GitHub ↗
(
    object_path: list[str], stub: nodes.MypyFile, runtime_all_as_set: set[str]
)

Source from the content-addressed store, hash-verified

299
300
301def _verify_exported_names(
302 object_path: list[str], stub: nodes.MypyFile, runtime_all_as_set: set[str]
303) -> Iterator[Error]:
304 # note that this includes the case the stub simply defines `__all__: list[str]`
305 assert "__all__" in stub.names
306 public_names_in_stub = {m for m, o in stub.names.items() if o.module_public}
307 names_in_stub_not_runtime = sorted(public_names_in_stub - runtime_all_as_set)
308 names_in_runtime_not_stub = sorted(runtime_all_as_set - public_names_in_stub)
309 if not (names_in_runtime_not_stub or names_in_stub_not_runtime):
310 return
311 yield Error(
312 object_path + ["__all__"],
313 (
314 "names exported from the stub do not correspond to the names exported at runtime. "
315 "This is probably due to things being missing from the stub or an inaccurate `__all__` in the stub"
316 ),
317 # Pass in MISSING instead of the stub and runtime objects, as the line numbers aren't very
318 # relevant here, and it makes for a prettier error message
319 # This means this error will be ignored when using `--ignore-missing-stub`, which is
320 # desirable in at least the `names_in_runtime_not_stub` case
321 stub_object=MISSING,
322 runtime_object=MISSING,
323 stub_desc=(f"Names exported in the stub but not at runtime: {names_in_stub_not_runtime}"),
324 runtime_desc=(
325 f"Names exported at runtime but not in the stub: {names_in_runtime_not_stub}"
326 ),
327 )
328
329
330@functools.lru_cache

Callers 1

verify_mypyfileFunction · 0.85

Calls 3

sortedFunction · 0.85
ErrorClass · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…