Skip to content

Commit

Permalink
MAINT: Apply pre-commit hooks (#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Oct 29, 2023
1 parent 9afda0a commit cb90320
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
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

0 comments on commit cb90320

Please sign in to comment.