-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
With 0.750 and this code:
from typing import TypeVar, Sequence
_T = TypeVar('_T')
class NeighborList:
def __init__(self, items: Sequence[_T]) -> None:
self._items = items
def print_sorted(self) -> None:
print(sorted(enumerate(self.items), key=lambda e: e[1])) # <---
@property
def items(self) -> Sequence[_T]:
return self._items
nl = NeighborList([1, 2, 3])
nl.print_sorted()
I get:
x.py:12: error: Argument 1 to "sorted" has incompatible type "enumerate[_T]"; expected "Iterable[Tuple[int, _T]]"
x.py:12: error: Argument 1 to "enumerate" has incompatible type "Sequence[_T]"; expected "Iterable[_T]"
I bisected this, it was introduced in 9d5d0e9 (part of #7933, fix for #7863).
When I remove the property and use self._items
directly, things seem to be fine.
#7434 looks somewhat similar to me, but I don't think it's the same issue.
Metadata
Metadata
Assignees
Labels
No labels