Skip to content

openpyxl: Add _WorkbookChild / ReadOnlyWorksheet / Workbook annotations#11677

Merged
srittau merged 3 commits into
python:mainfrom
Avasam:worksheet-type-annotations
Apr 1, 2024
Merged

openpyxl: Add _WorkbookChild / ReadOnlyWorksheet / Workbook annotations#11677
srittau merged 3 commits into
python:mainfrom
Avasam:worksheet-type-annotations

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Mar 31, 2024

Extracted from #9511 and added all _WorkbookChild / ReadOnlyWorksheet / Workbook annotations I could find using the following search:

I updated parameter annotations for all of the following mathcing "whole word" regex:

  • worksheet[,:\)]
  • .*_worksheet[,:\)]
  • sheets?[,:\)]
  • ws[,:\)]
  • parent[,:\)]
  • wb[,:\)]
  • workbook[,:\)]
  • .*_workbook[,:\)]

And the return type of functions matching the following:

  • def .*?workbook.*?\(
  • def .*?sheet.*?\(

(note I looked for a few other variations of the above words, but they didn't match anything)

Now that typeshed has support for PEP 696, Workbook should probably be made generic on read_only and write_only, but that's out of scope for this PR. (see #9940 )

Added refs to python/mypy#6700

@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.

Looks reasonable after spot checking.

@srittau srittau merged commit 0cea0bc into python:main Apr 1, 2024
@Avasam Avasam deleted the worksheet-type-annotations branch April 1, 2024 13:41
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.

2 participants