Various improvements to stubgen (#7921)
This improves various things in stubgen. Here are some notable changes:
* Filter out some bad type comments (or comments that look like them) since
these generate parse errors, and stubgen can't recover from them.
* Remove the initial generated comment from all stubs, since it gets easily
out of date and seems redundant, especially for packages with hundreds of
submodules.
* Don't generate a blocking error for inconsistent MROs.
* Make docstring parser more robust.
* Tweak the level of logging. Add `--verbose` and `--quiet` flags.
* Export imported names that aren't references in the module.
* Fix handling of unreachable code.
* Fix signatures of various C extension methods.
* Skip modules that are not useful or can cause trouble, such as vendored
modules and tests.
* Preserve `@abstractproperty`.
* Fix clashes between `typing.Any` and a class named `Any` (etc.).
* Translate imports to vendored `six` to refer to normal `six`.
* Add ad-hoc whitelisting of specific definitions that should be exported.