Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Remove ignore Ruff rule RET503 #3209

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,10 @@ def _merge_page(
if hasattr(
self.indirect_reference.pdf, "_add_object"
): # ---------- to detect PdfWriter
return self._merge_page_writer(
self._merge_page_writer(
page2, page2transformation, ctm, over, expand
)
return
except (AssertionError, AttributeError):
pass

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

clean(content, images, forms)
page.replace_contents(content)
return [], []

def remove_images(
self,
Expand Down Expand Up @@ -3105,6 +3106,7 @@ def find_outline_item(
o = cast(TreeObject, o["/Next"])
else:
return None
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are two issues here:

  • We always return None - why does this check trigger at all?
  • If this is a valid case, we should have a test for it as well.

Copy link
Collaborator

@stefan6419846 stefan6419846 Mar 23, 2025

Choose a reason for hiding this comment

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

Looking at this again, this might indeed be correct, but untested.


def find_bookmark(
self,
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ ignore = [
"PYI042", # Type alias `mode_str_type` should be CamelCase
"RET501", # Do not explicitly `return None` in function if it is the only possible return value
"RET502", # Do not implicitly `return None` in function able to return non-`None` value
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RET505", # Unnecessary `else` after `return` statement
"RUF001", # Detect confusable Unicode-to-Unicode units. Introduces bugs
"RUF002", # Detect confusable Unicode-to-Unicode units. Introduces bugs
Expand Down