* Run black code formatter on tempfile.pyi
* Use Literal to improve SpooledTemporaryFile
Previously, SpooledTemporaryFile was always an AnyStr.
Now, we load a SpooledTemporaryFile[bytes] if we open in bytes mode,
and we load a SpooledTemporaryFile[str] if we open in str mode.
The `update` method calls `self[key] = message` for each `(key, message)`
pair so it also accepts all the same message types as the `__setitem__`
method. Fix the signature so that the inputs are not restricted to
`Message` instances or to instance of the `_MessageType` type parameter,
but to the more reluctant `_MessageData` type alias.
Nothing in the standard library documentation for the string module suggests that the value associated with any key in the mapping parameter(or kwds) to Template.substitute and Template.safe_substitute should be a string. In fact any object can be used, for example
Template("$number is a number.").substitute({"number": 1})
The above code sample currently causes an error message like this:
error: Dict entry 0 has incompatible type "str": "int"; expected "str": "str"
which obviously shouldn't be emitted. Also a similar logic is already in place for methods in the Formatter class. However as I saw the notice about loose types above the Formatter class, I opted to use `object` instead of `Any` as the implementation inside the affected functions just uses the built-in str function on values inside mappings.
* mailbox: Make stub-only helpers private
These HasIteritems and HasItems protocols don't exist in the real
mailbox module so prefix them with underscore to indicate they are
private.
* mailbox: Fix type of message argument
The Mailbox.add and Mailbox.__setitem__ methods take a message argument
which can be anything that is convertible to a Message. Fix the
signatures accordingly.
`multiprocessing.dummy` exports names that were not yet listed in the typeshed stub:
```python
>>> from multiprocessing import dummy as mpdummy
>>> imported_objects = (
... (name, obj) for name, obj in vars(mpdummy).items()
... if name in mpdummy.__all__ and not obj.__module__.startswith("multiprocessing.dummy")
... )
>>> print(*(f"{name}: {obj.__module__}" for name, obj in sorted(imported_objects)), sep="\n")
Barrier: threading
BoundedSemaphore: threading
Condition: threading
Event: threading
JoinableQueue: queue
Lock: _thread
Queue: queue
RLock: threading
Semaphore: threading
current_process: threading
```
Of these, only `JoinableQueue` was listed.
find_module is documented to return a tuple (file, pathname,
description) where "file" is open file object and "description" a tuple
(suffix, mode, type). The type of "file" was wrong ("str" instead of
"IO[Any]") as well as that of "suffix" ("IO[Any]" instead of "str");
probably those type definitions were swapped.
Fixes#3466.
Fix errors discovered by running typeshed check on Windows. This is a temporary fix for #3446 (in long term we should figure out why these were not caught by typeshed CI).
I also remove an outdated comment while I am at it.
Until this is removed from the standard library, it probably should stay in the typing.
Also update both 2 and 3 definitions to use Mapping[Any, Any], rather than Dict[Any, Any].