This includes two things to sync up with recent runtime updates:
* Move `Final`, `@final`, `Literal`, and `TypedDict` to `typing` (`typing_extensions` still defines or re-exports them)
* Rename `@typing.runtime` to `@typing.runtime_checkable`, while keeping `@runtime` as a backwards-compatible alias in `typing_extensions`.
Since these properties do not have a setter, be explicit with the
`@property` decorator. This will allow type checkers to see that
assignment of these attributes is an error.
See https://github.com/python/typeshed/pull/3027#discussion_r289623016
for some related context.
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.