-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Mypy does not report as an error passing a list[str]
where tuple[str, ...]
is expected.
#16576
Comments
Thanks for the report, but please try to minimize your bug reports so it easier to see the issue. I haven't looked very closely but this seems related to |
Yes, sorry, I'm not really sure where the issue is, so I just wrote an example that reproduces the issue. Indeed there is a |
Then the way to minimize is to remove code from the example until you get the simplest possible example that still shows the problem. |
Thanks @JelleZijlstra, a reduced version: from __future__ import annotations
import functools
from typing import Callable, TypeVar
TR = TypeVar("TR")
def dummy(key_callable: Callable[[], str], value_callable: Callable[[], TR]) -> TR:
_ = key_callable()
value = value_callable()
return value
class Thing:
def _get_cache_key(self, obj_id: str, expand: tuple[str, ...]) -> str:
return f"key.{obj_id}{'.'.join(expand)}"
def _get_an_object(self, obj_id: str, expand: list[str]) -> str:
return f"value.{obj_id}{'.'.join(expand)}"
def get_obj(self, obj_id: str, expand: list[str]) -> str:
return dummy(
functools.partial(self._get_cache_key, obj_id, expand),
functools.partial(self._get_an_object, obj_id, expand),
) https://mypy-play.net/?mypy=latest&python=3.11&gist=e258fc60b107eecfe1754db8311c9c6f |
list[str]
where tuple[str, ...]
is expected.list[str]
where tuple[str, ...]
is expected.
Bug Report
Mypy does not report as a bug passing a
list[str]
wheretuple[str, ...]
is expected.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=032e779ff0e6eb9f72a3c902a9f6dba7
Expected Behavior
Mypy identifies the issue.
Actual Behavior
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: