stubgen: include __all__ in output by JelleZijlstra · Pull Request #16356 · python/mypy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stubtest doesn't complain if __all__ is omitted at runtime, no (though I think it should -- see #13300).

We're in a bit of a catch-22 here if the runtime __all__ has members that don't exist at runtime. In terms of typeshed's CI:

  1. If __all__ is different in the stub to what it is at runtime, then stubtest will complain.
  2. If __all__ in the stub contains members that don't exist in the stub, pyright will complain.
  3. If __all__ is present at runtime but omitted in the stub, then neither will complain but, as you say, maybe stubtest should complain...

I think you're right that emitting __all__ as it is at runtime is probably the least opinionated thing to do. Maybe we should just add a comment in the test cases to say that we know this is weird, but there's no obviously correct solution for this situation