Commit Graph

15 Commits

Author SHA1 Message Date
Eric Traut
04c74640f0 Removed imported symbols that are not accessed or re-exported (#4387)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-05 22:49:17 -07:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
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.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Bruce Merry
fb398b1d59 Use the ReadableBuffer type in more places (#4245)
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.
2020-06-22 06:17:24 -07:00
Shantanu
0a69743bca hashlib: fix argument kinds, update for py39 (#4006)
* hashlib: add usedforsecurity in py39
* hashlib: fix positional-only args, arg names
* hashlib: fix positional and keyword only args for blake
* hashlib: add usedforsecurity to blake
2020-05-17 01:31:12 +02:00
Shantanu
e3dfaa6608 hashlib: fix arguments (#3626)
* hashlib: fix argument names
* hashlib: add default values to scrypt, make args Optional
2020-01-22 10:20:40 +01:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Sebastian Rittau
95eff73ab2 Drop Python 3.3 support from several stubs (#2265)
* Drop Python 3.3 support from several stubs

* Revert wrong socketserver changes
2018-06-20 16:49:47 -07:00
Henri Bai
44f7869c80 Fix blake2 binding (#1663)
* 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
2017-11-08 19:39:55 -08:00
James Elford
2d4cd76765 Add new hashes introduced in Python 3.6 (#1268)
* 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
2017-05-22 07:57:31 -07:00
Nathan Henrie
b8a3f9359f Update pbkdf2_hmac argument names for 3.4+ (#1241)
* 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+
2017-05-04 21:09:07 -07:00
David Euresti
db84eb7844 Fix hashlib to accept multiple data types (#918) 2017-02-06 17:24:48 -08:00
Jakub Stasiak
f5bfee6f35 Finish Python 3 hashlib stub (#179) 2016-05-04 08:29:16 -07:00
Matthias Kramm
94c9ce8fd0 Consistently use '= ...' for optional parameters. 2015-11-09 13:55:02 -08:00
Matthias Kramm
337abed05a add (overwrite with) mypy stubs, if available 2015-09-30 09:59:44 -07:00