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

MAINT: Apply pre-commit hooks #2277

Merged
merged 2 commits into from
Oct 29, 2023
Merged
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
15 changes: 4 additions & 11 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2218,18 +2218,12 @@ def clean(content: ContentStream, images: List[str], forms: List[str]) -> None:
if (
(
operator == b"INLINE IMAGE"
and (
cast(ObjectDeletionFlag, to_delete)
& ObjectDeletionFlag.INLINE_IMAGES
)
and (to_delete & ObjectDeletionFlag.INLINE_IMAGES)
)
or (operator in jump_operators)
or (
operator == b"Do"
and (
cast(ObjectDeletionFlag, to_delete)
& ObjectDeletionFlag.XOBJECT_IMAGES
)
and (to_delete & ObjectDeletionFlag.XOBJECT_IMAGES)
and (operands[0] in images)
)
):
Expand All @@ -2256,8 +2250,7 @@ def clean_forms(
try:
content: Any = None
if (
to_delete
& ObjectDeletionFlag.XOBJECT_IMAGES
to_delete & ObjectDeletionFlag.XOBJECT_IMAGES
and o["/Subtype"] == "/Image"
):
content = NullObject() # to delete the image keeping the entry
Expand Down Expand Up @@ -2314,7 +2307,7 @@ def remove_images(
Remove images from this output.

Args:
to_delete : The type of images to be deleted
to_delete : The type of images to be deleted
(default = all images types)
ignore_byte_string_object: deprecated
"""
Expand Down
8 changes: 5 additions & 3 deletions pypdf/generic/_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def clone(
except Exception:
pass

visited: Set[Tuple[int, int]] = set()
visited: Set[Tuple[int, int]] = set() # (idnum, generation)
d__ = cast(
"DictionaryObject",
self._reference_clone(self.__class__(), pdf_dest, force_duplicate),
Expand All @@ -205,7 +205,7 @@ def _clone(
pdf_dest: PdfWriterProtocol,
force_duplicate: bool,
ignore_fields: Optional[Sequence[Union[str, int]]],
visited: Set[Tuple[int, int]],
visited: Set[Tuple[int, int]], # (idnum, generation)
) -> None:
"""
Update the object from src.
Expand Down Expand Up @@ -293,7 +293,9 @@ def _clone(
except Exception:
cur_obj = None
for s, c in objs:
c._clone(s, pdf_dest, force_duplicate, ignore_fields, visited)
c._clone(
s, pdf_dest, force_duplicate, ignore_fields, visited
)

for k, v in src.items():
if k not in ignore_fields:
Expand Down