Fixes#975
And a few more things I noticed while reading the tempfile docs.
In 3.5, most functions in tempfile were changed to accept either str or bytes in their prefix and suffix arguments, and return bytes or str accordingly. This seemed like a case for AnyStr.
We were missing tempdirb and tempprefixb, added in 3.5.
TemporaryFile and others were declared as returning BinaryIO, but they actually return either binary or text IO depending on the mode passed in. I changed the return type to IO[Any], similar to builtins.open.
* Make pickle accept IO[str] instead of BinaryIO.
This makes the following code work:
pickle.Unpickler(cStringIO.StringIO())
(Which didn't work before because cStringIO.StringIO inherits "only"
from IO[str], not BinaryIO)
* Use bytes instead of str.
* Fix a few return types in stdlib/2/inspect.pyi.
* Rename _FrameRecord to _FrameInfo
* Correct some return types in itertools.pyi from Iterable to Iterator.
* Improve types for xml.etree.ElementTree
Update signatures to reflect the following peculiarities of the
ElementTree library:
- The elementtree library accepts unicode or bytes for most xml values
in python2, and coerces everywhere -- but in python3, only str makes
sense.
- In python 2, the library produces str or unicode instances
unpredictably, depending on whether the xml is decodeable as ascii or
not. In python 3, it always produces str instances.
- The parser functions accept unicode or bytes in 2 and 3 -- again, will
coerce individual instances so heterogeneous lists are ok.
- In python 3, the tostring functions produce bytes or str, depending on
the value of the 'encoding' parameter.
* improve docs
* Improve ElementFactory type by specifying dict of 2nd arg
* Missing special attributes of class instances inherited from object
* object.__reduce__ returns a tuple
It's up to its inheritors to return either a tuple or a string.
The concurrent.futures.Future class's set_exception() method might be
called with a BaseException that is not an Exception, so change
set_exception()'s parameter type from Exception to BaseException. The
exception set via set_exception() is returned by exception(), so
change exception()'s return type from Exception to BaseException.
A previous PR led mypy to refuse to instantiate ChainMap,
because it had unimplemented abstract methods.
This PR adds the abstract methods to the stub,
which is enough to persuade mypy to allow instantiating
ChainMap.
As of Python 3.3, copymode, copystat, copy and copy2 take an
optional argument, 'follow_symlinks'.
As of Python 3.3, copytree and move return the destination.
As of Python 3.5, move takes an optional copy function.
As of Python 3.3, disk_usage, chown, which and get_terminal_size
were added.