- Move Loader and ModuleType into _importlib_modulespec.pyi.
- Add "import X as X" for these to types.pyi and importlib/abc.pyi.
The goal is to ensure mypy -i still works, to fix https://github.com/python/mypy/issues/1797.
decode_header accepts a parameter of type str or Header, but the
stub for decode_header types the parameter as Header. Change
that to Union[Header, str].
* urllib.parse: Make return type of unquote_from_bytes str.
* urllib.parse: Reject encoding when quote is passed bytes.
encoding and errors must not be supplied to quote_plus and
quote if the first parameter is a bytes, or a TypeError is raised.
So overload quote and do not put encoding and errors in the
version where bytes is the first parameter.
quote and quote_plus also allow string and safe to be of different
types. Also allow that in the stubs.
* Fix some misspelled method names that were also missing 'self'
* Initial stubs for importlib.machinery
* Use importlib.machinery.ModuleSpec everywhere
* Change (Py3) email message payload type
The docstring of the Message get_payload method indicates that the
possible return types include None and bytes. Additionally the
set_payload method accepts bytes. Therefore I've changed the
PayloadType to include bytes and the get_payload return type to be an
Optional PayloadType.
* Change email (Py3) message_from_file IO types
Instead of using TextIO and BinaryIO use IO[str] and IO[bytes]
respectively to match the type returned by the open builtin. This
follows the recommendations in #283.
The error that prompts this is reproduced via:
```
from email import message_from_file
with open('email') as file_:
email = message_from_file(file_)
```
Argument 1 to "message_from_file" has incompatible type IO[Any]; expected "TextIO"
Discovered while adding MyPy for code that was implementing
MutableMapping and using the update function like this:
```python
class CaseInsensitiveDict(collections.MutableMapping):
def __init__(self, data=None, **kwargs):
# type: (dict, **Any) -> None
self._store = dict() # type: dict
if data is None:
data = {}
self.update(data, **kwargs)
```
This commit adds kwargs to MutableMapping to allow this.
Shout out to Tim Abbott for assisting me with this.