Update shlex to be compatible with changes from python 3.6: https://docs.python.org/3/library/shlex.html
Those changes should fix issues I've encountered:
```
main.py:10: error: No overload variant of "list" matches argument types [shlex.shlex]
main.py:10: error: Unexpected keyword argument "punctuation_chars" for "shlex"
/usr/local/lib/mypy/typeshed/stdlib/3/shlex.pyi:29: note: "shlex" defined here
```
caused by
```python
list(shlex(string, posix=True, punctuation_chars=True))
```
This fixes all current partial signatures, as well as adding anything
that I happened to have to work out whilst fixing those partial
signatures.
The stubs remain incomplete.
* Use typing.ContextManager for multiprocessing context managers
Prior to this commit, the types for __enter__ and __exit__ were not
fully defined; this addresses that.
* Move Pool class stub to multiprocessing.pool
This is where the class is actually defined in the stdlib.
* Ensure that __enter__ on Pool subclasses returns the subclass
This ensures that:
```py
class MyPool(Pool):
def my_method(self): pass
with MyPool() as pool:
pool.my_method()
```
type-checks correctly.
* Update the signature of BaseContext.Pool to match Pool.__init__
* Restore multiprocessing.Pool as a function
And also add comments to note that it should have an identical signature
to multiprocessing.context.BaseContext.Pool (because it is just that
method partially applied).
This change modifies the PIPE, STDOUT, and DEVNULL constants in the
subprocess module to be of type 'int'.
Note that the Python 2 subprocess module was already typed this way;
this commit is just updating the Python 3 subprocess module in the same
way.
* Make configparser.RawConfigParser.__getitem__ return a SectionProxy
This reflects the code in the cpython tree and makes the following
(valid) code type-check correctly:
```
from configparser import ConfigParser
config = ConfigParser()
config.read_dict({'section': {'key': 'false'}})
assert config['section'].getboolean('key') is False
```
* RawConfigParser.items() returns SectionProxys not mappings
Because .items() uses __getitem__ to produce second item in each tuple.
* section argument to RawConfigParser.items is Optional
* Add comment explaining the status of RawConfigParser.items
TL;DR, we're hitting https://github.com/python/mypy/issues/3805 when
implemented correctly as an override, and
https://github.com/python/mypy/issues/1855 when we try to work around
that with a union.
* Correctly implement RawConfigParser.items overloading
* RawConfigParser.items(str) returns a List not an Iterable
RawConfigParser.read has code explicitly supporting PathLike objects.
Also removed an unused import and widened the accepted type from
Sequence to Iterable.
In Python 3 (but not Python 2), `object().__dir__()` works and returns a list of strings.
This is relevant when implementing a custom `__dir__` that invokes `super().__dir__()`.
Also change multiprocessing.Queue's put and get timeout arguments to
allow None.
This fixes a problem with logging.handlers.QueueHandler and
QueueListener not accepting a multiprocessing.Queue as the queue
argument.
Declaring the Queue now needs to note what it will be used for. eg.
q = multiprocessing.Queue() # type: multiprocessing.Queue[List[Any]]
After mypy [started hiding](https://github.com/python/mypy/pull/3706) imported names in stubs unless `from ... import ...` is used, we found an error with stubs of ast module.
It looks like ast module should re-export everything in `_ast` and according to PEP 484, it can do that by doing `from _ast import *`, so this is what this PR does.
* Added stub for sre_parse(py3)
* Fixed return type of SubPattern.__getitem__
* Typo
* Fix for issue related to error class
* Added stub for sre_constants(py3)
* Added missing import
It is currently required to shut up mypy when run with `--strict`
or `--disallow-subclassing-any`. The `Any` base class is currently
the only way to allow passing an instance of `Mock` to functions
expecting other classes (as is Mock's purpose).
These stubs are identical in Python 2 and 3, but I believe they
should not be merged, because there are numerous other modules
in the encodings package, and some only exist in some Python
versions. I don't think we can support that in the 2and3
directory.