-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
operator.itemgetter can accept any hashable type #558
Comments
Oh, there are lots of interesting things we could do here. Maybe it should be a generic function, e.g. @overload
def itemgetter(item: int) -> Callable[[Sequence[T]], T]: ...
@overload
def itemgetter(item: K) -> Callable[[Mapping[K, V], V]: ... except the latter doesn't work yet because it introduces a type variable in the (callable) return type (I think the reason is related to python/mypy#1927). The So maybe for now we need something with a lots of |
Even if it would work, doesn't overload resolution rely only on the input arguments? In that case
would fail to typecheck, due to the the returned function expecting a |
Yeah, that's one of the challenges. It needs something that supports --Guido (mobile) |
python/mypy#2153
basically, the following is valid Python code:
in my case I got the error message with a more mundane string key, thus yielding this error:
The text was updated successfully, but these errors were encountered: