-
Notifications
You must be signed in to change notification settings - Fork 663
Closed
Description
Description of the bug
Document.pages() is type-hinted as returning Page, but actually returns a generator yielding Pages — it should be hinted as returning Iterator[Page].
How to reproduce the bug
With this saved in repro.pdf:
import fitz
pdf = fitz.open('foo.pdf')
for page in pdf.pages():
print(page)
print('success')pyright complains:
$ pyright repro.py
/home/nick/code/hca/health/src/pdf_rotator/repro.py
/home/nick/code/hca/health/src/pdf_rotator/repro.py:3:13 - error: "Page" is not iterable
"__iter__" method not defined (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
but the code runs (with foo.pdf present):
$ python repro.py
page 0 of foo.pdf
success
PyMuPDF version
1.24.0
Operating system
Linux
Python version
3.12
Metadata
Metadata
Assignees
Labels
No labels