Using izip with up to 6 arguments will retain the arguments' type information,
using izip with 7 and more arguments will discard type information about the
generated tuple items.
Also fix signature of IO.seek, IO.truncate, IO.write, and MutableMapping.update
Fixes#1016
Note: I couldn't put typing.pyi in 2and3 because of an import cycle when adding `import sys` to 2/typing.pyi
* add compileall stubs to 3 and add types to the ones in 2
Didn't merge the stubs because all functions have additional parameters since 3.2,
so there would be no shared code between 2 and 3.
* add comment
- Add sys.version_info checks (mypy now supports them)
- Went over Python 3 docs and corrected a few things
- Reexport things that are imported from opcode
This works towards fixing #924. To make the changes easier to review, I'm planning to
fix the issue in two steps:
- This commit makes the 3 stubs compatible with py2
- The next PR will move the 3 stubs to 2and3 and remove the 2 stubs
I wrote this code by diffing the files in third_party/{2,3}/requests and making
appropriate changes to the Python 3 stubs (mostly str/Text stuff). I verified
that the 3 stubs now pass mypy when parsed as 2.7, but I don't have an annotated
requests-using codebase to test on.
CONTRIBUTING.md says to prefer ... Not the most impactful change but fixing
these will allow us to lint for it in the future and get a consistent style.
The stubs for `unittest.TestCase.assertCountEqual()` specify the parameters are Sequences; in fact the method works fine with Iterables, as the first thing the method does is convert them to lists. [1] The docs do say sequences, but it appears there is no reason they cannot be Iterables.
[1]: https://github.com/python/cpython/blob/master/Lib/unittest/case.py#L1156
* Complete the tokenize module type hints
* Add missing import for Optional
* Use a 3.5-style named tuple, untokenize speaks with forked tongue so use Any
* Use explicit types for fields
third_party/2/concurrent/futures is for the Python 2 backport of the
concurrent.futures package from Python 3. In Python 3, all exceptions
are derived from BaseException, but Python 2 also supports exceptions
that are old-style objects (which don't derive from BaseException).
Switch from BaseException to Any to allow old-style exceptions.
All old-style objects are instances of types.InstanceType, so an
alternative to Any is Union[BaseException, types.InstanceType]. This
would help avoid accidentally passing a non-BaseException new-style
object to Future.set_exception(). However, only Executors call that
function (usually), and it's not clear that mypy understands old-style
objects and their relationship to types.InstanceType, so Any is
thought to be the more practical choice.