* 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
str.translate requires a Mapping or Sequence (in essence, anything
with __getitem__), not a Dict.
str.maketrans in the one-argument form only converts character string
keys to their unicode ordinal, leaving any of the values untouched.
This mapping may use both integers or strings as keys at the same time.
str.maketrans in the multi-argument form returns a dict with any of the
values str, int or None, as recognized by str.translate.
List is used but not imported. According to PEP-484 "Suggested syntax for Python 2.7 and straddling code" it should be imports.
"Like other type comments, any names used in the annotations must be imported or defined by the module containing the annotation.".
Also order the typing import list, because it looks nicer.
Specifically, this solves a problem in code such as:
with ThreadPoolExecutor() as p: ...
Where the p variable would be typed as an abstract `Executor`, rather than the specific `ThreadPoolExecutor` as expected.
This follows documentation and code which allows to use both bool and Text.
Update all the prompt arguments for all *option functions in click.decorators module
since they're mostly proxying the call to option setting desired defaults.
closes#1693
There were two problems AFAICT:
- There are multiple Loader classes without a common base class,
so this should really be a union or a protocol.
- The argument is supposed to be a class, not an instance.
Rather than figuring out a fix (which would probably require some
nasty refactoring) I'm just going back to the old situation where
these arguments are implicitly annotated with `Any`.
See also https://github.com/python/typeshed/pull/1657#pullrequestreview-72049880
* Replace `self` with `cls` in classmethod
* Group classmethods together, as in the actual stub
* Use float instead of Union[int, float] in coding style example
* Add stub for unittest.mock.patch.multiple()
* Use ... for default arguments in unittest.mock.patch() et al.
* Tighten type of create argument to patch() et al.
I disagree with the recommendation that users create incomplete stubs, because such stubs lead to false positive type checker errors (see for example #525). I would like to instead set a norm that all stubs should contain all public objects in the library they cover.
Makes heavier use of generics to minimize code. Fixes some incorrect
types. Also reordered to allow easy comparison against class listings
and documentation.
It also improves the type checking of contained values. Some methods
were removed because they are implemented by a base class (i.e.,
*__iter__()*, *__str__()*, and *__contains__()*). *__hash__()* was
removed because arrays are unhashable types.
This commit adds a few missing return types to the Python 3 textwrap
stubs and fleshes out the Python 2 textwrap stubs so they're on par with
the Python 3 version.
This change:
1. Changes the order of the arguments in Python 2 and Python 3
to match the order from the source code instead of the
documentation.
2. Adds other undocumented attributes besides whitespace_trans
(for consistency).
3. Moves the '*' argument in TextWrapper.__init__ for Python 3
to match the source code.
4. Made function stub formatting consistent with typeshed style
conventions.