Skip to content

Commit cb90320

Browse files
authored
MAINT: Apply pre-commit hooks (#2277)
1 parent 9afda0a commit cb90320

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

pypdf/_writer.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -2218,18 +2218,12 @@ def clean(content: ContentStream, images: List[str], forms: List[str]) -> None:
22182218
if (
22192219
(
22202220
operator == b"INLINE IMAGE"
2221-
and (
2222-
cast(ObjectDeletionFlag, to_delete)
2223-
& ObjectDeletionFlag.INLINE_IMAGES
2224-
)
2221+
and (to_delete & ObjectDeletionFlag.INLINE_IMAGES)
22252222
)
22262223
or (operator in jump_operators)
22272224
or (
22282225
operator == b"Do"
2229-
and (
2230-
cast(ObjectDeletionFlag, to_delete)
2231-
& ObjectDeletionFlag.XOBJECT_IMAGES
2232-
)
2226+
and (to_delete & ObjectDeletionFlag.XOBJECT_IMAGES)
22332227
and (operands[0] in images)
22342228
)
22352229
):
@@ -2256,8 +2250,7 @@ def clean_forms(
22562250
try:
22572251
content: Any = None
22582252
if (
2259-
to_delete
2260-
& ObjectDeletionFlag.XOBJECT_IMAGES
2253+
to_delete & ObjectDeletionFlag.XOBJECT_IMAGES
22612254
and o["/Subtype"] == "/Image"
22622255
):
22632256
content = NullObject() # to delete the image keeping the entry
@@ -2314,7 +2307,7 @@ def remove_images(
23142307
Remove images from this output.
23152308
23162309
Args:
2317-
to_delete : The type of images to be deleted
2310+
to_delete : The type of images to be deleted
23182311
(default = all images types)
23192312
ignore_byte_string_object: deprecated
23202313
"""

pypdf/generic/_data_structures.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def clone(
188188
except Exception:
189189
pass
190190

191-
visited: Set[Tuple[int, int]] = set()
191+
visited: Set[Tuple[int, int]] = set() # (idnum, generation)
192192
d__ = cast(
193193
"DictionaryObject",
194194
self._reference_clone(self.__class__(), pdf_dest, force_duplicate),
@@ -205,7 +205,7 @@ def _clone(
205205
pdf_dest: PdfWriterProtocol,
206206
force_duplicate: bool,
207207
ignore_fields: Optional[Sequence[Union[str, int]]],
208-
visited: Set[Tuple[int, int]],
208+
visited: Set[Tuple[int, int]], # (idnum, generation)
209209
) -> None:
210210
"""
211211
Update the object from src.
@@ -293,7 +293,9 @@ def _clone(
293293
except Exception:
294294
cur_obj = None
295295
for s, c in objs:
296-
c._clone(s, pdf_dest, force_duplicate, ignore_fields, visited)
296+
c._clone(
297+
s, pdf_dest, force_duplicate, ignore_fields, visited
298+
)
297299

298300
for k, v in src.items():
299301
if k not in ignore_fields:

0 commit comments

Comments
 (0)