File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ import subprocess
3+
4+ import pymupdf
5+
6+
7+ def run (command , check = 1 ):
8+ print (f'Running: { command } ' )
9+ subprocess .run (command , shell = 1 , check = check )
10+
11+ def test_py_typed ():
12+ print (f'test_py_typed(): { pymupdf .__path__ = } ' )
13+ run ('pip uninstall -y mypy' )
14+ run ('pip install mypy' )
15+ root = os .path .abspath (f'{ __file__ } /../..' )
16+
17+ # Run mypy on this .py file; it will fail at `import pymypdf` if the
18+ # pymupdf install does not have a py.typed file.
19+ #
20+ # This doesn't actually check pymupdf's typing. It looks like
21+ # we can do that with `mypy -m pymupdf`, but as of 2026-1-18 this
22+ # gives many errors such as:
23+ #
24+ # ...site-packages/pymupdf/__init__.py:15346: error: point_like? has no attribute "y" [attr-defined]
25+ #
26+ # It's important to use `--no-incremental`, otherwise if one has
27+ # experimented with `mypy -m pymupdf`, this test will get the
28+ # same failures, via `.mypy_cache/` directories.
29+ #
30+ # We run in sub-directory to avoid spurious mypy errors
31+ # if there is a local mupdf/ directory.
32+ #
33+ run (f'cd { root } /tests && mypy --no-incremental { os .path .abspath (__file__ )} ' )
You can’t perform that action at this time.
0 commit comments