openpyxl: Workbook opened in readonly mode should return `ReadOnlyCell | EmptyCell` from `worksheet.rows`
Open
Nobody has claimed this yet.
stubs: improvement
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
Currently the type hints for worksheet.rows returns Cell objects. However, opening a workbook in readonly mode results in ReadOnlyCell or EmptyCell objects being returned.
>>> workbook = openpyxl_excel_reader.load_workbook(file, read_only=True)
>>> worksheet = workbook.worksheets[0] # openpyxl.worksheet._read_only.ReadOnlyWorksheet
>>> [row for row in worksheet.rows]
[
(<ReadOnlyCell 'Sheet1'.A1>, <EmptyCell>, <ReadOnlyCell 'Sheet1'.C1>),
(<ReadOnlyCell 'Sheet1'.A2>, <EmptyCell>, <ReadOnlyCell 'Sheet1'.C2>),
]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the openpyxl stub defining worksheet.rows and inspect how the regular and read-only worksheet cell types are represented. Update the return typing to account for ReadOnlyCell and EmptyCell, then run the relevant type checks or tests to confirm both worksheet modes are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100