You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Openpyxl iter_rows is no more compatible with next function #13151
c:\Users\Avasam\Desktop\openpyxl_type_test.py
c:\Users\Avasam\Desktop\openpyxl_type_test.py:6:17 - information: Type of "Workbook()["sheet"].iter_rows()" is "Generator[tuple[Cell | MergedCell, ...], None, None]"
c:\Users\Avasam\Desktop\openpyxl_type_test.py:7:17 - information: Type of "next(Workbook()["sheet"].iter_rows())" is "tuple[Cell | MergedCell, ...]"
c:\Users\Avasam\Desktop\openpyxl_type_test.py:8:17 - information: Type of "Workbook()["sheet"].iter_rows(values_only=True)" is "Generator[tuple[str | float | datetime | None, ...], None, None]"
c:\Users\Avasam\Desktop\openpyxl_type_test.py:9:17 - information: Type of "next(Workbook()["sheet"].iter_rows(values_only=True))" is "tuple[str | float | datetime | None, ...]"
c:\Users\Avasam\Desktop\openpyxl_type_test.py:10:17 - information: Type of "Workbook()["sheet"].iter_rows(values_only=unknown_values_only)" is "Generator[tuple[Cell | MergedCell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]"
c:\Users\Avasam\Desktop\openpyxl_type_test.py:11:17 - information: Type of "next(Workbook()["sheet"].iter_rows(values_only=unknown_values_only))" is "tuple[Cell | MergedCell, ...] | tuple[str | float | datetime | None, ...]"
0 errors, 0 warnings, 6 informations
I do not understand why a Generator is not considered as SupportsNext
The error seem to imply that the generic type of the expected SupportsNext is what's mismatched (notice how in your logs, there's no MergedCell as part of the expected type).
My guess would be that you are assigning to a predefined value that doesn't match the inferred return type of next. But it's hard to say without a complete reproducer.
Activity
mutricyl commentedon Nov 28, 2024
looks like commit 82b5fcc is the culprit. Any thought @Avasam ?
Avasam commentedon Nov 29, 2024
@mutricyl Do you think you could provide a more complete example? I am unable to replicate.
mypy --strict C:\Users\Avasam\Desktop\openpyxl_type_test.pypyright C:\Users\Avasam\Desktop\openpyxl_type_test.pyThe error seem to imply that the generic type of the expected
SupportsNextis what's mismatched (notice how in your logs, there's noMergedCellas part of the expected type).My guess would be that you are assigning to a predefined value that doesn't match the inferred return type of
next. But it's hard to say without a complete reproducer.mutricyl commentedon Nov 29, 2024
I got the point ! I spent some time replicating the issue and there is a replicable example:
So I bascially miss the
MergedCellin my return type...Thanks for the help @Avasam , I'll close the issue.