Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
720b9bb
#3591: Extending typing to tests; cover generic and scripts folder files
iso-techdev Feb 26, 2026
44f2ba0
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 12, 2026
88ab7d6
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 16, 2026
8f849a6
Ci now runs the checking. New test files also included
iso-techdev Mar 16, 2026
84675bd
fixing workflow
iso-techdev Mar 16, 2026
2984380
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 17, 2026
0fa3f6a
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 17, 2026
b88e66b
(used black formatter) added type to new test files and methods added…
iso-techdev Mar 17, 2026
912a521
Fixing the workflow, reverting changes, fixing comments
iso-techdev Mar 18, 2026
ee4b135
fixing ci
iso-techdev Mar 18, 2026
1de2a7e
fixing the ci
iso-techdev Mar 18, 2026
49cf240
ruff was commented out from the requirements
iso-techdev Mar 18, 2026
007e957
fixed the ci, regenerated ci requirements to include the missing stubs
iso-techdev Mar 19, 2026
7c7d08c
fixing comments
iso-techdev Mar 20, 2026
1fc402c
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 24, 2026
0f21b9f
fxing comments, and new files
iso-techdev Mar 24, 2026
3b8098d
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 27, 2026
8516bc2
Fixed the comments
iso-techdev Mar 27, 2026
2886bfe
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 30, 2026
1a93cda
Merge branch 'main' into issue-3591-PR-1
iso-techdev Mar 31, 2026
8f6e1b2
Merge branch 'main' into issue-3591-PR-1
iso-techdev Apr 7, 2026
86b9c82
fixing comment
iso-techdev Apr 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ jobs:
ruff check .
- name: Test with mypy
run : |
mypy pypdf
mypy pypdf tests/generic tests/scripts
Comment thread
iso-techdev marked this conversation as resolved.
Outdated
- name: Install docs requirements
run: |
pip install -r requirements/docs.txt
Expand Down
2 changes: 1 addition & 1 deletion pypdf/generic/_image_xobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _handle_flate(
size: tuple[int, int],
data: bytes,
mode: mode_str_type,
color_space: str,
color_space: ArrayObject,
Comment thread
stefan6419846 marked this conversation as resolved.
Outdated
colors: int,
obj_as_text: str,
) -> tuple[Image.Image, str, str, bool]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@ disallow_incomplete_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unused_configs = true
exclude = ['venv', '.venv', 'tests', 'make_release.py']
exclude = ['venv', '.venv', 'make_release.py']
2 changes: 1 addition & 1 deletion tests/generic/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_text_string_object__looks_like_bom(source: bytes, expected: str) -> Non


@pytest.mark.enable_socket
def test_text_string_object__wrongly_detected_bom():
def test_text_string_object__wrongly_detected_bom() -> None:
url = "https://github.com/user-attachments/files/24401507/minimal.pdf"
name = "issue3587.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
Expand Down
23 changes: 13 additions & 10 deletions tests/generic/test_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
try:
import resource
except ImportError:
resource = None
resource = None # type: ignore[assignment]


def test_dictionary_object__get_next_object_position():
def test_dictionary_object__get_next_object_position() -> None:
reader = PdfReader(RESOURCE_ROOT / "crazyones.pdf")

# reader.xref = {0: {7: 15, 9: 10245, 12: 939, 14: 2999, 16: 4982, 18: 9949, 22: 11160}}
Expand All @@ -49,12 +49,14 @@ def test_dictionary_object__get_next_object_position():
) == 15


def test_tree_object__cyclic_reference(caplog):
def test_tree_object__cyclic_reference(caplog: pytest.LogCaptureFixture) -> None:
writer = PdfWriter()
child1 = writer._add_object(DictionaryObject())
child2 = writer._add_object(DictionaryObject({NameObject("/Next"): child1}))
child3 = writer._add_object(DictionaryObject({NameObject("/Next"): child2}))
child1.get_object()[NameObject("/Next")] = child3
obj = child1.get_object()
if isinstance(obj, dict):
Comment thread
stefan6419846 marked this conversation as resolved.
Outdated
obj[NameObject("/Next")] = child3
tree = TreeObject()
tree[NameObject("/First")] = child2
tree[NameObject("/Last")] = writer._add_object(DictionaryObject())
Expand All @@ -64,7 +66,7 @@ def test_tree_object__cyclic_reference(caplog):


@pytest.mark.enable_socket
def test_array_object__clone_same_object_multiple_times(caplog):
def test_array_object__clone_same_object_multiple_times(caplog: pytest.LogCaptureFixture) -> None:
url = "https://github.com/user-attachments/files/25412858/Draft_OSMF_financial_statement_2013.pdf"
name = "issue2991.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url=url, name=name)))
Expand All @@ -76,7 +78,7 @@ def test_array_object__clone_same_object_multiple_times(caplog):
assert caplog.messages == []


def test_array_object__clone_same_stream_multiple_times():
def test_array_object__clone_same_stream_multiple_times() -> None:
writer = PdfWriter()

# Unique streams.
Expand All @@ -87,7 +89,8 @@ def test_array_object__clone_same_stream_multiple_times():

# Shared streams.
shared_streams = [StreamObject() for _ in range(3)]
[shared_stream.set_data(f"Shared stream {index}".encode()) for index, shared_stream in enumerate(shared_streams)]
for index, shared_stream in enumerate(shared_streams):
Comment thread
stefan6419846 marked this conversation as resolved.
shared_stream.set_data(f"Shared stream {index}".encode())

# Add to writer.
writer._add_object(stream1)
Expand Down Expand Up @@ -121,7 +124,7 @@ def test_array_object__clone_same_stream_multiple_times():


@pytest.mark.enable_socket
def test_dictionary_object__read_from_stream__limit():
def test_dictionary_object__read_from_stream__limit() -> None:
name = "read_from_stream__length_2gb.pdf"
url = "https://github.com/user-attachments/files/25842437/read_from_stream__length_2gb.pdf"

Expand Down Expand Up @@ -164,7 +167,7 @@ def limit_virtual_memory() -> None:
@pytest.mark.enable_socket
@pytest.mark.skipif(condition=resource is None, reason="Does not have 'resource' module.")
@pytest.mark.skipif(sys.platform == "darwin", reason="RLIMIT_AS is unreliable.")
def test_dictionary_object__read_from_stream__no_limit(tmp_path):
def test_dictionary_object__read_from_stream__no_limit(tmp_path: Path) -> None:
pdf_path_str, env, limit_virtual_memory = _prepare_test_dictionary_object__read_from_stream__no_limit(tmp_path)

source_file = tmp_path / "script.py"
Expand Down Expand Up @@ -196,7 +199,7 @@ def test_dictionary_object__read_from_stream__no_limit(tmp_path):
@pytest.mark.enable_socket
@pytest.mark.skipif(condition=resource is None, reason="Does not have 'resource' module.")
@pytest.mark.skipif(sys.platform == "darwin", reason="RLIMIT_AS is unreliable.")
def test_dictionary_object__read_from_stream__no_limit__path(tmp_path):
def test_dictionary_object__read_from_stream__no_limit__path(tmp_path: Path) -> None:
pdf_path_str, env, limit_virtual_memory = _prepare_test_dictionary_object__read_from_stream__no_limit(tmp_path)

source_file = tmp_path / "script.py"
Expand Down
Loading
Loading