Skip to content
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

openpyxl: Cell | MergedCell annotations #13092

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Nov 25, 2024

Extracted and completed from #9511

This basically comes down to typing Worksheet._cells then working up the tree of references.
Then I checked all existing Cell annotations as a sanity check.

This does result in a few extra Cell | MergedCell return types, which may negatively affect some users since no Cell-like type inherits from Cell. This is the same issue as #11718 and could be solved in the same way.

Note that this does not address #9940

@@ -51,6 +51,7 @@ class Worksheet(_WorkbookChild):
ORIENTATION_PORTRAIT: Final = "portrait"
ORIENTATION_LANDSCAPE: Final = "landscape"

_cells: dict[tuple[int, int], _CellOrMergedCell] # private but very useful to understand typing
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could just comment this out before merging, Users shouldn't be using this, but it's a useful note.

This comment has been minimized.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit 74ea509 into python:main Nov 25, 2024
48 checks passed
@Avasam Avasam deleted the openpyxl-Cell-or-MergedCell-annotations branch November 25, 2024 15:19
@overload
def iter_rows(
self, min_row: int | None, max_row: int | None, min_col: int | None, max_col: int | None, values_only: bool
) -> Generator[tuple[Cell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]: ...
) -> (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to issue #13151 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants