Skip to content

Commit 6aeb659

Browse files
src/ tests/: allow typing tools to see Page.find_tables().
Fixes #4932.
1 parent 64b6bc5 commit 6aeb659

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
import atexit
1414
import binascii
1515
import collections
16+
import glob
17+
import importlib.util
1618
import inspect
1719
import io
1820
import math
1921
import os
2022
import pathlib
21-
import glob
2223
import re
2324
import string
2425
import sys
@@ -30,7 +31,6 @@
3031
import zipfile
3132

3233
from . import extra
33-
import importlib.util
3434

3535
# Set up g_out_log and g_out_message from environment variables.
3636
#
@@ -11383,6 +11383,9 @@ def extend_textpage(self, tpage, flags=0, matrix=None):
1138311383
mupdf.fz_run_page( page, dev, ctm, mupdf.FzCookie())
1138411384
mupdf.fz_close_device( dev)
1138511385

11386+
def find_tables(self, **kwargs):
11387+
return table.find_tables(self, **kwargs)
11388+
1138611389
@property
1138711390
def first_annot(self):
1138811391
"""First annotation."""
@@ -25571,8 +25574,7 @@ def _mupdf_devel(make_links=True):
2557125574
recover_quad = utils.recover_quad
2557225575
recover_span_quad = utils.recover_span_quad
2557325576

25574-
from .table import find_tables
25575-
Page.find_tables = find_tables
25577+
from . import table
2557625578

2557725579

2557825580
class FitzDeprecation(DeprecationWarning):

tests/test_typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ def test_py_typed():
4343

4444
def _test_4903(page: pymupdf.Page) -> float: # In 1.27.1, error: Variable "pymupdf.Page" is not valid as a type
4545
return page.rect.width # In 1.27.1, error: pymupdf.Page? has no attribute "rect"
46+
47+
def _test_4932(page: pymupdf.Page):
48+
page.find_tables()

0 commit comments

Comments
 (0)