Skip to content

Commit 3d44536

Browse files
authored
STY: Run black (#2370)
1 parent eb3e22d commit 3d44536

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

docs/user/forms.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ The PDF form stores form fields as annotations with the subtype "\Widget". This
4848

4949
```python
5050
from pypdf import PdfReader
51+
5152
reader = PdfReader("form.pdf")
5253
fields = reader.get_fields()
5354
```
5455

5556
```python
5657
from pypdf import PdfReader
5758
from pypdf.constants import AnnotationDictionaryAttributes
59+
5860
reader = PdfReader("form.pdf")
5961
fields = []
6062
for page in reader.pages:

pypdf/_text_extraction/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def handle_tj(
214214
rtl_dir: bool,
215215
visitor_text: Optional[Callable[[Any, Any, Any, Any, Any], None]],
216216
) -> Tuple[str, bool]:
217-
218217
m = mult(tm_matrix, cm_matrix)
219218
orientation = orient(m)
220219
if orientation in orientations and len(operands) > 0:

pypdf/_xobj_image_helpers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,13 @@ def bits2byte(data: bytes, size: Tuple[int, int], bits: int) -> bytes:
198198
expected_count = 2 * nb
199199
if len(lookup) != expected_count:
200200
if len(lookup) < expected_count:
201-
raise PdfReadError(f"Not enough lookup values: Expected {expected_count}, got {len(lookup)}.")
201+
raise PdfReadError(
202+
f"Not enough lookup values: Expected {expected_count}, got {len(lookup)}."
203+
)
202204
if not check_if_whitespace_only(lookup[expected_count:]):
203-
raise PdfReadError(f"Too many lookup values: Expected {expected_count}, got {len(lookup)}.")
205+
raise PdfReadError(
206+
f"Too many lookup values: Expected {expected_count}, got {len(lookup)}."
207+
)
204208
lookup = lookup[:expected_count]
205209
colors_arr = [lookup[:nb], lookup[nb:]]
206210
arr = b"".join(

tests/test_xobject_image_helpers.py

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ def test_handle_flate__image_mode_1():
3333
data = b"\x00\xe0\x00"
3434
lookup = DecodedStreamObject()
3535
expected_data = [
36-
(66, 66, 66), (66, 66, 66), (66, 66, 66),
37-
(0, 19, 55), (0, 19, 55), (0, 19, 55),
38-
(66, 66, 66), (66, 66, 66), (66, 66, 66)
36+
(66, 66, 66),
37+
(66, 66, 66),
38+
(66, 66, 66),
39+
(0, 19, 55),
40+
(0, 19, 55),
41+
(0, 19, 55),
42+
(66, 66, 66),
43+
(66, 66, 66),
44+
(66, 66, 66),
3945
]
4046

4147
# No trailing data.
@@ -44,9 +50,11 @@ def test_handle_flate__image_mode_1():
4450
size=(3, 3),
4551
data=data,
4652
mode="1",
47-
color_space=ArrayObject([NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]),
53+
color_space=ArrayObject(
54+
[NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]
55+
),
4856
colors=2,
49-
obj_as_text="dummy"
57+
obj_as_text="dummy",
5058
)
5159
assert expected_data == list(result[0].getdata())
5260

@@ -56,32 +64,52 @@ def test_handle_flate__image_mode_1():
5664
size=(3, 3),
5765
data=data,
5866
mode="1",
59-
color_space=ArrayObject([NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]),
67+
color_space=ArrayObject(
68+
[NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]
69+
),
6070
colors=2,
61-
obj_as_text="dummy"
71+
obj_as_text="dummy",
6272
)
6373
assert expected_data == list(result[0].getdata())
6474

6575
# Trailing non-whitespace character.
6676
lookup.set_data(b"\x42\x42\x42\x00\x13\x37\x12")
67-
with pytest.raises(PdfReadError, match=r"^Too many lookup values: Expected 6, got 7\.$"):
77+
with pytest.raises(
78+
PdfReadError, match=r"^Too many lookup values: Expected 6, got 7\.$"
79+
):
6880
_handle_flate(
6981
size=(3, 3),
7082
data=data,
7183
mode="1",
72-
color_space=ArrayObject([NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]),
84+
color_space=ArrayObject(
85+
[
86+
NameObject("/Indexed"),
87+
NameObject("/DeviceRGB"),
88+
NumberObject(1),
89+
lookup,
90+
]
91+
),
7392
colors=2,
74-
obj_as_text="dummy"
93+
obj_as_text="dummy",
7594
)
7695

7796
# Not enough lookup data.
7897
lookup.set_data(b"\x42\x42\x42\x00\x13")
79-
with pytest.raises(PdfReadError, match=r"^Not enough lookup values: Expected 6, got 5\.$"):
98+
with pytest.raises(
99+
PdfReadError, match=r"^Not enough lookup values: Expected 6, got 5\.$"
100+
):
80101
_handle_flate(
81102
size=(3, 3),
82103
data=data,
83104
mode="1",
84-
color_space=ArrayObject([NameObject("/Indexed"), NameObject("/DeviceRGB"), NumberObject(1), lookup]),
105+
color_space=ArrayObject(
106+
[
107+
NameObject("/Indexed"),
108+
NameObject("/DeviceRGB"),
109+
NumberObject(1),
110+
lookup,
111+
]
112+
),
85113
colors=2,
86-
obj_as_text="dummy"
114+
obj_as_text="dummy",
87115
)

0 commit comments

Comments
 (0)