Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--fastparser + --py2 - leads to mypy thinking -1 is out of range for a tuple #1788

Closed
OrenLeaffer opened this issue Jul 1, 2016 · 1 comment
Assignees

Comments

@OrenLeaffer
Copy link

OrenLeaffer commented Jul 1, 2016

The test case for this is pretty simple, access the last element of a tuple using -1.

$ cat t.py
(1,)[-1]
$ python2.7 t.py
$ python3.5 t.py
$ mypy --py2  --fast-parser t.py
t.py:1: error: Tuple index out of range
$ mypy --fast-parser t.py
$ mypy --py2 t.py
$
@ddfisher
Copy link
Collaborator

ddfisher commented Jul 1, 2016

Thanks for the bug report! This should be fixed in typed-ast shortly.

ddfisher added a commit to python/typed_ast that referenced this issue Jul 1, 2016
Python 2 represents negative numeric literals as Num(n=-NUMBER), but Python 3 represents them as UnaryOp(op=USub(), operand=Num(n=NUMBER)). This commit makes the conversions module actually make this change.

Fixes python/mypy#1788.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants