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]]
E.g. it's legal to call traceback.format_exception(None, None, None). In
particular, this change makes the following idiom type-check:
import traceback
import sys
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.format_exception(exc_type, exc_value, exc_traceback)
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.