-
Notifications
You must be signed in to change notification settings - Fork 767
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
Argument type is partially unknown for map #1400
Comments
This behavior is a known limitation of bidirectional type inference. In the first case (with variable In cases like this, you have several options:
lst2 = list(map(list[int], lst))
lst2_temp: map[list[int]] = map(list, lst)
lst2 = list(lst2_temp)
lst2 = list(cast(map[list[int]], map(list, lst)))
lst2: list[list[int]] = list(map(list, lst)) # type: ignore |
Alright, that sounds good. Specializing list sounds like the best approach here. |
Actually, why doesn't specialization work for this case? lst = [[1,2,3],[4]]
tup: tuple[tuple[int, ...], ...] = tuple(map(tuple[int, ...], lst))
# ^^^^^^^^^^^^^^^^^^^^^^^^^
# No overloads for "__init__" match the provided arguments
# Argument types: (Type[tuple[int, ...]], list[list[int]]) Pylance(reportGeneralTypeIssues) |
That's a bug! Thanks for reporting it. This will be fixed in the next release. |
This issue has been fixed in version 2021.6.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202161-9-june-2021 |
Environment data
Expected behaviour
No errors, type checker should know that map(list, list[list[X]]) -> list[list[X]]
Actual behaviour
Argument type is partially unknown for map(list, lst)
Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: