Skip to content

Commit 89033cb

Browse files
authored
STY: Apply pre-commit (#1188)
1 parent 8a27fa4 commit 89033cb

File tree

6 files changed

+36
-11
lines changed

6 files changed

+36
-11
lines changed

PyPDF2/_merger.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
from ._encryption import Encryption
3232
from ._page import PageObject
3333
from ._reader import PdfReader
34-
from ._utils import StrByteType, deprecate_with_replacement, deprecate_bookmark, str_
34+
from ._utils import (
35+
StrByteType,
36+
deprecate_bookmark,
37+
deprecate_with_replacement,
38+
str_,
39+
)
3540
from ._writer import PdfWriter
3641
from .constants import GoToActionArguments
3742
from .constants import PagesAttributes as PA
@@ -426,7 +431,9 @@ def _trim_outline(
426431
if outline_item["/Page"] is None:
427432
continue
428433
if pdf.pages[j].get_object() == outline_item["/Page"].get_object():
429-
outline_item[NameObject("/Page")] = outline_item["/Page"].get_object()
434+
outline_item[NameObject("/Page")] = outline_item[
435+
"/Page"
436+
].get_object()
430437
new_outline.append(outline_item)
431438
prev_header_added = True
432439
break

PyPDF2/_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@
4141
FileIO,
4242
)
4343
from os import SEEK_CUR
44-
from typing import Any, Callable, Dict, Optional, Pattern, Tuple, Union, overload
44+
from typing import (
45+
Any,
46+
Callable,
47+
Dict,
48+
Optional,
49+
Pattern,
50+
Tuple,
51+
Union,
52+
overload,
53+
)
4554

4655
try:
4756
# Python 3.10+: https://www.python.org/dev/peps/pep-0484/

PyPDF2/_writer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
StreamType,
5959
_get_max_pdf_version_header,
6060
b_,
61-
deprecate_with_replacement,
6261
deprecate_bookmark,
62+
deprecate_with_replacement,
6363
)
6464
from .constants import AnnotationDictionaryAttributes
6565
from .constants import CatalogAttributes as CA
@@ -83,7 +83,6 @@
8383
BooleanObject,
8484
ByteStringObject,
8585
ContentStream,
86-
_create_outline_item,
8786
DecodedStreamObject,
8887
Destination,
8988
DictionaryObject,
@@ -97,14 +96,15 @@
9796
StreamObject,
9897
TextStringObject,
9998
TreeObject,
99+
_create_outline_item,
100100
create_string_object,
101101
)
102102
from .types import (
103103
BorderArrayType,
104104
FitType,
105105
LayoutType,
106-
PagemodeType,
107106
OutlineItemType,
107+
PagemodeType,
108108
ZoomArgsType,
109109
ZoomArgType,
110110
)

tests/test_merger.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ def test_merge():
6161
"The FitV fit", 0, outline_item, (255, 0, 15), True, True, "/FitV", 10
6262
)
6363
merger.add_outline_item(
64-
"The FitR fit", 0, outline_item, (255, 0, 15), True, True, "/FitR", 10, 20, 30, 40,
64+
"The FitR fit",
65+
0,
66+
outline_item,
67+
(255, 0, 15),
68+
True,
69+
True,
70+
"/FitR",
71+
10,
72+
20,
73+
30,
74+
40,
6575
)
6676
merger.add_outline_item(
6777
"The FitB fit", 0, outline_item, (255, 0, 15), True, True, "/FitB"

tests/test_reader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ def get_dest_pages(x):
596596
return pdf.get_destination_page_number(x) + 1
597597

598598
out = []
599-
for oi in outline: # oi can be destination or a list:preferred to just print them
599+
# oi can be destination or a list:preferred to just print them
600+
for oi in outline:
600601
out.append(get_dest_pages(oi))
601602

602603

tests/test_writer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ def test_writer_operations():
6262
writer.add_outline_item(
6363
"The FitR fit", 0, oi, (255, 0, 15), True, True, "/FitR", 10, 20, 30, 40
6464
)
65-
writer.add_outline_item(
66-
"The FitB fit", 0, oi, (255, 0, 15), True, True, "/FitB"
67-
)
65+
writer.add_outline_item("The FitB fit", 0, oi, (255, 0, 15), True, True, "/FitB")
6866
writer.add_outline_item(
6967
"The FitBH fit", 0, oi, (255, 0, 15), True, True, "/FitBH", 10
7068
)

0 commit comments

Comments
 (0)