Skip to content

Commit e9be734

Browse files
committed
fix: apply code formatting with ruff format
The CI was failing on code formatting checks, not linting rules. Applied automatic formatting to resolve the formatting differences that were causing the build to fail. - Fixed formatting in src/nutrient_dws/api/direct.py - Fixed formatting in src/nutrient_dws/builder.py - Fixed formatting in tests/integration/test_new_tools_integration.py All linting rules continue to pass.
1 parent c76074c commit e9be734

File tree

3 files changed

+30
-76
lines changed

3 files changed

+30
-76
lines changed

src/nutrient_dws/api/direct.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -822,16 +822,14 @@ def duplicate_pdf_pages(
822822
if page_index < 0:
823823
# For negative indexes, we can't use end+1 (would be 0 for -1)
824824
# The API might handle negative indexes differently
825-
parts.append({
826-
"file": "file",
827-
"pages": {"start": page_index, "end": page_index + 1}
828-
})
825+
parts.append(
826+
{"file": "file", "pages": {"start": page_index, "end": page_index + 1}}
827+
)
829828
else:
830829
# For positive indexes, create single-page range (end is exclusive)
831-
parts.append({
832-
"file": "file",
833-
"pages": {"start": page_index, "end": page_index + 1}
834-
})
830+
parts.append(
831+
{"file": "file", "pages": {"start": page_index, "end": page_index + 1}}
832+
)
835833

836834
# Build instructions for duplication
837835
instructions = {"parts": parts, "actions": []}

src/nutrient_dws/builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ def _map_tool_to_action(self, tool: str, options: dict[str, Any]) -> dict[str, A
244244
for key, value in options.items():
245245
# Convert snake_case to camelCase for API
246246
camel_key = "".join(
247-
word.capitalize() if i else word
248-
for i, word in enumerate(key.split("_"))
247+
word.capitalize() if i else word for i, word in enumerate(key.split("_"))
249248
)
250249
action[camel_key] = value
251250

tests/integration/test_new_tools_integration.py

Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def sample_pdf_with_sensitive_data(self, tmp_path):
6565
def test_create_redactions_preset_ssn(self, client, sample_pdf_with_sensitive_data):
6666
"""Test creating redactions with SSN preset."""
6767
result = client.create_redactions_preset(
68-
sample_pdf_with_sensitive_data,
69-
preset="social-security-number"
68+
sample_pdf_with_sensitive_data, preset="social-security-number"
7069
)
7170
assert_is_pdf(result)
7271
assert len(result) > 0
@@ -77,9 +76,7 @@ def test_create_redactions_preset_with_output_file(
7776
"""Test creating redactions with preset and saving to file."""
7877
output_path = tmp_path / "redacted_preset.pdf"
7978
result = client.create_redactions_preset(
80-
sample_pdf_with_sensitive_data,
81-
preset="email",
82-
output_path=str(output_path)
79+
sample_pdf_with_sensitive_data, preset="email", output_path=str(output_path)
8380
)
8481
assert result is None
8582
assert output_path.exists()
@@ -89,20 +86,15 @@ def test_create_redactions_regex(self, client, sample_pdf_with_sensitive_data):
8986
"""Test creating redactions with regex pattern."""
9087
# Pattern for simple date format (MM/DD/YYYY)
9188
result = client.create_redactions_regex(
92-
sample_pdf_with_sensitive_data,
93-
pattern=r"\b\d{2}/\d{2}/\d{4}\b",
94-
case_sensitive=False
89+
sample_pdf_with_sensitive_data, pattern=r"\b\d{2}/\d{2}/\d{4}\b", case_sensitive=False
9590
)
9691
assert_is_pdf(result)
9792
assert len(result) > 0
9893

9994
def test_create_redactions_text(self, client, sample_pdf_with_sensitive_data):
10095
"""Test creating redactions for exact text matches."""
10196
result = client.create_redactions_text(
102-
sample_pdf_with_sensitive_data,
103-
text="PDF",
104-
case_sensitive=False,
105-
whole_words_only=True
97+
sample_pdf_with_sensitive_data, text="PDF", case_sensitive=False, whole_words_only=True
10698
)
10799
assert_is_pdf(result)
108100
assert len(result) > 0
@@ -115,7 +107,7 @@ def test_create_redactions_with_appearance(self, client, sample_pdf_with_sensiti
115107
case_sensitive=False,
116108
appearance_fill_color="#FF0000",
117109
appearance_stroke_color="#000000",
118-
appearance_stroke_width=2
110+
appearance_stroke_width=2,
119111
)
120112
assert_is_pdf(result)
121113
assert len(result) > 0
@@ -147,29 +139,20 @@ def test_optimize_pdf_basic(self, client, sample_pdf_path):
147139
def test_optimize_pdf_grayscale(self, client, sample_pdf_path):
148140
"""Test PDF optimization with grayscale options."""
149141
result = client.optimize_pdf(
150-
sample_pdf_path,
151-
grayscale_text=True,
152-
grayscale_graphics=True,
153-
grayscale_images=True
142+
sample_pdf_path, grayscale_text=True, grayscale_graphics=True, grayscale_images=True
154143
)
155144
assert_is_pdf(result)
156145
assert len(result) > 0
157146

158147
def test_optimize_pdf_reduce_quality(self, client, sample_pdf_path):
159148
"""Test PDF optimization with reduced image quality."""
160-
result = client.optimize_pdf(
161-
sample_pdf_path,
162-
reduce_image_quality=50
163-
)
149+
result = client.optimize_pdf(sample_pdf_path, reduce_image_quality=50)
164150
assert_is_pdf(result)
165151
assert len(result) > 0
166152

167153
def test_optimize_pdf_linearize(self, client, sample_pdf_path):
168154
"""Test PDF optimization with linearization."""
169-
result = client.optimize_pdf(
170-
sample_pdf_path,
171-
linearize=True
172-
)
155+
result = client.optimize_pdf(sample_pdf_path, linearize=True)
173156
assert_is_pdf(result)
174157
assert len(result) > 0
175158

@@ -180,7 +163,7 @@ def test_optimize_pdf_with_output_file(self, client, sample_pdf_path, tmp_path):
180163
sample_pdf_path,
181164
grayscale_images=True,
182165
reduce_image_quality=70,
183-
output_path=str(output_path)
166+
output_path=str(output_path),
184167
)
185168
assert result is None
186169
assert output_path.exists()
@@ -214,19 +197,14 @@ def sample_pdf_path(self):
214197

215198
def test_password_protect_user_password(self, client, sample_pdf_path):
216199
"""Test password protection with user password only."""
217-
result = client.password_protect_pdf(
218-
sample_pdf_path,
219-
user_password="test123"
220-
)
200+
result = client.password_protect_pdf(sample_pdf_path, user_password="test123")
221201
assert_is_pdf(result)
222202
assert len(result) > 0
223203

224204
def test_password_protect_both_passwords(self, client, sample_pdf_path):
225205
"""Test password protection with both user and owner passwords."""
226206
result = client.password_protect_pdf(
227-
sample_pdf_path,
228-
user_password="user123",
229-
owner_password="owner456"
207+
sample_pdf_path, user_password="user123", owner_password="owner456"
230208
)
231209
assert_is_pdf(result)
232210
assert len(result) > 0
@@ -240,8 +218,8 @@ def test_password_protect_with_permissions(self, client, sample_pdf_path):
240218
"print": False,
241219
"modification": False,
242220
"extract": True,
243-
"annotations": True
244-
}
221+
"annotations": True,
222+
},
245223
)
246224
assert_is_pdf(result)
247225
assert len(result) > 0
@@ -254,7 +232,7 @@ def test_password_protect_with_output_file(self, client, sample_pdf_path, tmp_pa
254232
user_password="secret",
255233
owner_password="admin",
256234
permissions={"print": True, "modification": False},
257-
output_path=str(output_path)
235+
output_path=str(output_path),
258236
)
259237
assert result is None
260238
assert output_path.exists()
@@ -288,9 +266,7 @@ def sample_pdf_path(self):
288266
def test_set_pdf_metadata_title_author(self, client, sample_pdf_path):
289267
"""Test setting PDF title and author."""
290268
result = client.set_pdf_metadata(
291-
sample_pdf_path,
292-
title="Test Document",
293-
author="Test Author"
269+
sample_pdf_path, title="Test Document", author="Test Author"
294270
)
295271
assert_is_pdf(result)
296272
assert len(result) > 0
@@ -304,7 +280,7 @@ def test_set_pdf_metadata_all_fields(self, client, sample_pdf_path):
304280
subject="Testing PDF Metadata",
305281
keywords="test, pdf, metadata, nutrient",
306282
creator="Nutrient DWS Python Client",
307-
producer="Test Suite"
283+
producer="Test Suite",
308284
)
309285
assert_is_pdf(result)
310286
assert len(result) > 0
@@ -316,7 +292,7 @@ def test_set_pdf_metadata_with_output_file(self, client, sample_pdf_path, tmp_pa
316292
sample_pdf_path,
317293
title="Output Test",
318294
keywords="output, test",
319-
output_path=str(output_path)
295+
output_path=str(output_path),
320296
)
321297
assert result is None
322298
assert output_path.exists()
@@ -364,10 +340,7 @@ def sample_instant_json(self, tmp_path):
364340

365341
def test_apply_instant_json_from_file(self, client, sample_pdf_path, sample_instant_json):
366342
"""Test applying Instant JSON from file."""
367-
result = client.apply_instant_json(
368-
sample_pdf_path,
369-
sample_instant_json
370-
)
343+
result = client.apply_instant_json(sample_pdf_path, sample_instant_json)
371344
assert_is_pdf(result)
372345
assert len(result) > 0
373346

@@ -382,10 +355,7 @@ def test_apply_instant_json_from_bytes(self, client, sample_pdf_path):
382355
}
383356
]
384357
}"""
385-
result = client.apply_instant_json(
386-
sample_pdf_path,
387-
json_bytes
388-
)
358+
result = client.apply_instant_json(sample_pdf_path, json_bytes)
389359
assert_is_pdf(result)
390360
assert len(result) > 0
391361

@@ -395,9 +365,7 @@ def test_apply_instant_json_with_output_file(
395365
"""Test applying Instant JSON with output file."""
396366
output_path = tmp_path / "annotated.pdf"
397367
result = client.apply_instant_json(
398-
sample_pdf_path,
399-
sample_instant_json,
400-
output_path=str(output_path)
368+
sample_pdf_path, sample_instant_json, output_path=str(output_path)
401369
)
402370
assert result is None
403371
assert output_path.exists()
@@ -444,10 +412,7 @@ def sample_xfdf(self, tmp_path):
444412

445413
def test_apply_xfdf_from_file(self, client, sample_pdf_path, sample_xfdf):
446414
"""Test applying XFDF from file."""
447-
result = client.apply_xfdf(
448-
sample_pdf_path,
449-
sample_xfdf
450-
)
415+
result = client.apply_xfdf(sample_pdf_path, sample_xfdf)
451416
assert_is_pdf(result)
452417
assert len(result) > 0
453418

@@ -459,21 +424,14 @@ def test_apply_xfdf_from_bytes(self, client, sample_pdf_path):
459424
<highlight page="0" rect="50,50,150,70"/>
460425
</annots>
461426
</xfdf>"""
462-
result = client.apply_xfdf(
463-
sample_pdf_path,
464-
xfdf_bytes
465-
)
427+
result = client.apply_xfdf(sample_pdf_path, xfdf_bytes)
466428
assert_is_pdf(result)
467429
assert len(result) > 0
468430

469431
def test_apply_xfdf_with_output_file(self, client, sample_pdf_path, sample_xfdf, tmp_path):
470432
"""Test applying XFDF with output file."""
471433
output_path = tmp_path / "xfdf_annotated.pdf"
472-
result = client.apply_xfdf(
473-
sample_pdf_path,
474-
sample_xfdf,
475-
output_path=str(output_path)
476-
)
434+
result = client.apply_xfdf(sample_pdf_path, sample_xfdf, output_path=str(output_path))
477435
assert result is None
478436
assert output_path.exists()
479437
assert_is_pdf(str(output_path))
@@ -483,4 +441,3 @@ def test_apply_xfdf_from_url(self, client, sample_pdf_path):
483441
"""Test applying XFDF from URL."""
484442
# This test would require a valid URL with XFDF content
485443
pass
486-

0 commit comments

Comments
 (0)