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

STY: Small increase of readability #2974

Merged
merged 7 commits into from
Dec 2, 2024
Merged
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
26 changes: 13 additions & 13 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,24 +1435,24 @@ def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO[Any]]:

def list_objects_in_increment(self) -> List[IndirectObject]:
"""
For debugging/analysis.
Provides the list of new/modified objects that will be written
For analysis or debugging.
Provides the list of new or modified objects that will be written
in the increment.
Deleted objects will not be freed but will become orphans.

Returns:
List of (new / modified) IndirectObjects
List of new or modified IndirectObjects

"""
original_hash_count = len(self._original_hash)
return [
cast(IndirectObject, self._objects[i]).indirect_reference
for i in range(len(self._objects))
cast(IndirectObject, obj).indirect_reference
for i, obj in enumerate(self._objects)
if (
self._objects[i] is not None
obj is not None
and (
i >= len(self._original_hash)
or cast(PdfObject, self._objects[i]).hash_bin()
!= self._original_hash[i]
i >= original_hash_count
or obj.hash_bin() != self._original_hash[i]
)
)
]
Expand All @@ -1462,11 +1462,11 @@ def _write_increment(self, stream: StreamType) -> None:
object_blocks = []
current_start = -1
current_stop = -2
original_hash_count = len(self._original_hash)
for i, obj in enumerate(self._objects):
if self._objects[i] is not None and (
i >= len(self._original_hash)
or cast(PdfObject, self._objects[i]).hash_bin()
!= self._original_hash[i]
if obj is not None and (
i >= original_hash_count
or obj.hash_bin() != self._original_hash[i]
):
idnum = i + 1
assert isinstance(obj, PdfObject) # mypy
Expand Down
Loading