* 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.
This reverts commit ba2c8d95ec.
This commit introduced some bugs (it used Pattern[Union[str, unicode]]
when it would need to be Union[Pattern[str], Pattern[unicode]]), and
- on further discussion - it's unclear if we want to allow this
additional flexibility. I'm reverting this diff for now, but we'll
revisit this after deciding on the upcoming proposal about how implicit
bytes/unicode conversions should be handled when typing Python 2.
timegm takes struct_time objects, which are NamedTuples that have 9 elements by default
That would not take Tuple[Int], so typeshed would report errors
This reverts commit d43adbe97e.
Here's a simple example of code that breaks with this PR:
from typing import Mapping, Dict, Tuple
a = {('0', '0'): 42} # type: Mapping[Tuple[str, str], int]
b = a.get(('1', '1'), 0)
This gives an error on the last line:
error: No overload variant of "get" of "dict" matches argument types [Tuple[builtins.str, builtins.str], builtins.int]
* json.loads() accepts unicode
* threading.BoundedSemaphore is subclass of Semaphore
* Added type annotations for logging/__init__.pyi and logging/handlers.pyi
* Changed style of variable declaration to fit the rest of the file
* Add empty stubs for gettext Translations subclasses
GNUTranslations and NullTranslations do not add any methods to the base
Translations class, so remove the TODO comment and just declare the
classes.
* Add missing types for py3 gettext.