Fixes#4288.
- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.
Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.
In two instances @overloads at the top of the file needed to be moved
due to psf/black#1490.
NodeVisitor recurses over an AST tree. When encountering a node, it
checks if a method called `visit_{node.__class__.__name__}` exists, and
calls it if so, otherwise calls the generic visitor.
Add the possible methods to NodeVisitor. This is not exactly correct,
since the methods don't *actually* exist on NodeVisitor, e.g.
`NodeVisitor().visit_Module(...)` doesn't work. But it's nice for
subclasses to know which methods they can override and which type they
should have.
This gets imported from `_ast`, so the definition was
redundant. This causes problems with the new mypy semantic
analyzer, as it will flag the redefinition as an error.
When we import typeshed internally at Dropbox, somehow the fact that
these files are all stubs gets lost (it's a long story...). This
causes errors like this:
.../stdlib/2/ast.pyi:6: error: Name 'typing' already defined (by an import)
The quickest way around this is to rename the import to _typing.
After mypy [started hiding](https://github.com/python/mypy/pull/3706) imported names in stubs unless `from ... import ...` is used, we found an error with stubs of ast module.
It looks like ast module should re-export everything in `_ast` and according to PEP 484, it can do that by doing `from _ast import *`, so this is what this PR does.
python/mypy#2380 showed a discrepancy between object and FunctionType in stdlib2. The first defined __doc__ to be str, the second Optional[str]. As FunctionType depends on object, this is no longer valid.
As suggested by @gvanrossum in python/mypy#2380, all __doc__ should be considered Optional.
(Final verdict was just to remove most __doc__ attributes since it's inherited from object.)