Skip to content
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8fa9c9b
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 21, 2025
96c92b9
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 21, 2025
552cc82
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 21, 2025
e1b86e3
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 21, 2025
0696f2a
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 22, 2025
95568ef
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 22, 2025
f5c84e5
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 23, 2025
d1d8ed6
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 23, 2025
f672d30
DEV: Remove ignore Ruff rule RET503
j-t-1 Mar 23, 2025
6c2a441
avoid noqa comment
stefan6419846 Mar 24, 2025
a7f49ca
Merge branch 'main' into RET503
j-t-1 Jul 18, 2025
14c7d6b
Fix errors
j-t-1 Jul 18, 2025
8c49df4
Fix another error
j-t-1 Jul 18, 2025
fef0f08
Fix RET502 erros
j-t-1 Jul 18, 2025
dd7dd06
Comment and fix error
j-t-1 Jul 18, 2025
3c86e28
Code coverage
j-t-1 Sep 21, 2025
f05e3f7
Merge branch 'main' into RET503
j-t-1 Sep 25, 2025
c7955f0
Merge branch 'py-pdf:main' into RET503
j-t-1 Sep 27, 2025
7918589
Merge branch 'main' into RET503
j-t-1 Oct 3, 2025
9262797
Modify test cases in test_merger.py
j-t-1 Oct 29, 2025
8bfe759
Add test case for finding outline item with None
j-t-1 Oct 29, 2025
510b901
Merge branch 'main' into RET503
j-t-1 Oct 29, 2025
4a49005
Remove comment
j-t-1 Oct 29, 2025
d2d5d48
Enhance test coverage for find_outline_item
j-t-1 Oct 29, 2025
b0867da
Remove test
j-t-1 Oct 29, 2025
5501e9b
Remove unnecessary return None from get_next
j-t-1 Oct 29, 2025
97c2524
Add return None
j-t-1 Oct 29, 2025
26920b5
Add pragma: no cover
j-t-1 Oct 29, 2025
0050de8
Add comment to explain pragma
j-t-1 Oct 29, 2025
d5ebefc
Remove tests
j-t-1 Oct 30, 2025
dce8ca9
Replace unreachable return statement with exception
j-t-1 Nov 3, 2025
525971b
Remove unused noqa directive
j-t-1 Nov 3, 2025
6003e03
Merge branch 'main' into RET503
stefan6419846 Nov 5, 2025
73adce0
Remove type ignore
j-t-1 Nov 5, 2025
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: 2 additions & 0 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ def _merge_page(
return self._merge_page_writer(
page2, page2transformation, ctm, over, expand
)
return None
except (AssertionError, AttributeError):
pass

Expand Down Expand Up @@ -1172,6 +1173,7 @@ def _merge_page(
self.replace_contents(ContentStream(new_content_array, self.pdf))
self[NameObject(PG.RESOURCES)] = new_resources
self[NameObject(PG.ANNOTS)] = new_annots
return None

def _merge_page_writer(
self,
Expand Down
2 changes: 2 additions & 0 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,7 @@ def clean_forms(

clean(content, images, forms, text_filters)
page.replace_contents(content)
return [], [] # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the ignore here?


def remove_images(
self,
Expand Down Expand Up @@ -3205,6 +3206,7 @@ def find_outline_item(
o = cast(TreeObject, o["/Next"])
else:
return None
return None # pragma: no cover

def reset_translation(
self, reader: Union[None, PdfReader, IndirectObject] = None
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ ignore = [
"PT014", # Ruff bug: Duplicate of test case at index 1 in `@pytest_mark.parametrize`
"PTH123", # `open()` should be replaced by `Path.open()`
"PYI042", # Type alias `mode_str_type` should be CamelCase
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RUF001", # Detect confusable Unicode-to-Unicode units. Introduces bugs
"RUF002", # Detect confusable Unicode-to-Unicode units. Introduces bugs
"S101", # Use of `assert` detected
Expand Down
9 changes: 8 additions & 1 deletion tests/test_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ def merger_operate(merger):
pdf_forms = RESOURCE_ROOT / "pdflatex-forms.pdf"
pdf_pw = RESOURCE_ROOT / "libreoffice-writer-password.pdf"

# string path:
merger.append(pdf_path)

# For code coverage
found_oi = merger.find_outline_item("nothing here")
assert found_oi is None

found_oi = merger.find_outline_item("nothing here 2", None)
assert found_oi is None

merger.append(outline)
merger.append(pdf_path, pages=pypdf.pagerange.PageRange(slice(0, 0)))
merger.append(pdf_forms)
Expand Down
Loading