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.
This is a follow-up on #4232. memoryview, hashlib, and hmac are updated
to use ReadableBuffer type instead of their own home-spun unions of
bytes, bytearray and whatever else each use case used. mmap is being
handled in #4244, and I'll leave BinaryIO for another day (or possibly
another person) because it's going to require some messy code
duplication because the relevant methods are defined in IO[AnyStr].
There's one corner case I'm not quite sure how best to handle: the
documentation for hmac.digest claim that the parmaeters have the same
meanings as in hmac.new, but in CPython the latter has an explicit check
that `key` is bytes or bytearray while the former works with a
memory-view. For now I've matched the documentation.
Also, the documentation for HMAC.update says that `msg` can be any type
supported by hashlib from Python 3.4; but I can't see anything in the
Python 2.7 implementation that would prevent it also taking bytes-like
objects, so I've not tried to treat Python 2 any different to Python 3.
* Fix blake2 binding
Currently calling `hashlib.blake2b` results in the following type errors:
Cannot instantiate abstract class '_BlakeHash' with abstract attributes 'copy', 'digest', 'hexdigest' and 'update'
Missing positional arguments "data", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node" in call to "_BlakeHash"
* Additional changes to reflect the hashlib implementation
Modifies the type signatures of:
* blake2b
* blake2s
* sha3_224
* sha3_256
* sha3_384
* sha3_512
* shake_128
* shake_256
To reflect the types that are implemented in the standard library.
These should be exposed as `type`s instead of `builtin_function_or_method`s.
e.g.
In [40]: type(hashlib.blake2b)
Out[40]: type
In [41]: type(hashlib.md5)
Out[41]: builtin_function_or_method
* sha3 family of hash functions
* shake variable length hashes that were introduced alongside sha3
* blake2 family of hash functions
* Mark VarLenHash as a private class, since it's not actually exported by hashlib
* Fix typos in my last, and mark hashlib.Hash as a private class since it isn't in the real hashlib
* Update pbkdf2_hmac for Python 3.5
- Use `iterations` instead of `rounds` if running on 3.5
- Change `dklen` to `Optional`
* Use `iterations` instead of `rounds` in 3.4+