Skip to content

Explicit List of Tuple do not support __setitem__ with index #1578

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

Closed
tharvik opened this issue May 25, 2016 · 1 comment
Closed

Explicit List of Tuple do not support __setitem__ with index #1578

tharvik opened this issue May 25, 2016 · 1 comment

Comments

@tharvik
Copy link
Contributor

tharvik commented May 25, 2016

from typing import List, Tuple

l = []  # type: List[Tuple[int, int]]
l.append((1, 2))

l[0] = 3, 4
l[:] = [(5, 6)]

gives

asd.py:6: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int, Tuple[builtins.int, builtins.int]]

so __setitem__ with slice works but not with index.

Not specifing the type does work (it is just an example, the code I'm working on need to explicit a specific variable).

I don't think it is an issue in typeshed as playing with builtins.list do not change a thing.
btw, simply exchanging the @overload __setitem__ gives me weirder errors, like

asd.py:1: note: In module imported here:
/home/tharvik/mypy/typeshed/stdlib/3/builtins.pyi: note: In class "list":
/home/tharvik/mypy/typeshed/stdlib/3/builtins.pyi:477: error: Signature of "__setitem__" incompatible with supertype "MutableSequence"
asd.py: note: At top level:
asd.py:6: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int, Tuple[builtins.int, builtins.int]]

The order shouldn't matter, right? (I didn't see it written in the PEP anyway)

rwbarton added a commit to rwbarton/mypy that referenced this issue May 26, 2016
Fixes python#1578, since list's __setitem__ is overloaded.
rwbarton added a commit to rwbarton/mypy that referenced this issue May 26, 2016
Fixes python#1578, since list's __setitem__ is overloaded.
rwbarton added a commit to rwbarton/mypy that referenced this issue May 26, 2016
Fixes python#1578, since list's __setitem__ is overloaded.
@rwbarton
Copy link
Contributor

rwbarton commented Jun 2, 2016

This has been fixed by #1596.

@rwbarton rwbarton closed this as completed Jun 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants