The main purpose of this change is to get the stubs into a
form that pytype will support with its next release. Since
these stubs already mostly use fully qualified names, this
will also increase consistency.
This also makes the flask stubs that depend on click parseable.
* In pytype_test, only parse files with the .pyi extension.
(There's a README in third_party/2and3/click/.)
* Annotate with ContextManager rather than using the
contextmanager decorator. This is shorter, removes a
dependency, and gets rid of the slight weirdness of a
decorator needing to be evaluated in a stub.
* Fix non-stub things.
Depending on if a "stream" or the "encoding" is given, the functions
either return None, str/unicode or bytes.
Use @overload fix distinguish those cases.
Also fix the functions using **kwds as they delegate their work to the
more generic functions: copy their signatures.
* yaml.dump(): Drop distinguishing encoding
As far as I know it's currently impossible to use "overloads with return
types depending on optional arguments" (Issue #5621). As "encoding" is
in the middle of 11 optional arguments, it would require ~ 2^6 overloads
for each of those 6 functions.
For now just return Any and wait for Issue #5621 to get fixed.
As a followup to the work done in #2767 and #2830, and to address a
piece of #66, most of the email_mime submodules aren't typed in six
under python2, only python3. Now they are.
Fixed several inconsistent parameter names so all instance methods take 'self' and all class methods take 'cls'. This avoids warnings or errors from linting tools that enforce standard naming conventions.
`dispatch_request` can accept arbitrary arguments and can return
different values. To keep this simple and in line with the rest of the
stubs (e.g. with `view_func: Callable[..., Any]`), `Any` is used for the
return value although it is too broad.
Closes#2795.
* default_exceptions is a dict of classes, not instances
* Correctly overload 'redirect' to get the proper return type
* Request.get_data() is an Any (not bytes), just like Response.get_data
Currently, iter_lines() doesn't have any type annotations despite the types being very similar to iter_content and the types can be pretty readily derived from the source.