More improvements to stubgen (#7951)
This includes many improvements to stubgen and a related mypy fix.
Here are the most useful ones:
* Use a separate process to do introspection of modules so that we can
recover if a module kills the current process on import, for example.
* Export all names imported from the current package by default.
Add `--export-less` stubgen flag to disable this behavior.
* Avoid a crash in semantic analysis if there's a bad property definition
(stubgen can generate these).
* Fix various issues with bad Python code being generated by stubgen.
* Ignore bad signatures in docstrings (this is still very ad-hoc, but it's a
bit more robust now).
* Try to find a module using `sys.path` if we can't import it.
* Skip some additional modules that may be runnable since they can cause
trouble when we try to introspect them.
This is again a big PR, but the commit history should be reasonably clean.