Skip to content

openpyxl: Cell | MergedCell annotations#13092

Merged
srittau merged 4 commits into
python:mainfrom
Avasam:openpyxl-Cell-or-MergedCell-annotations
Nov 25, 2024
Merged

openpyxl: Cell | MergedCell annotations#13092
srittau merged 4 commits into
python:mainfrom
Avasam:openpyxl-Cell-or-MergedCell-annotations

Conversation

@Avasam
Copy link
Copy Markdown
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

ORIENTATION_PORTRAIT: Final = "portrait"
ORIENTATION_LANDSCAPE: Final = "landscape"

_cells: dict[tuple[int, int], _CellOrMergedCell] # private but very useful to understand typing
Copy link
Copy Markdown
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.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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
@Avasam Avasam deleted the openpyxl-Cell-or-MergedCell-annotations branch November 25, 2024 15:19
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]: ...
) -> (
Copy link
Copy Markdown

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