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:
- If
__all__is different in the stub to what it is at runtime, then stubtest will complain. - If
__all__in the stub contains members that don't exist in the stub, pyright will complain. - 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