Skip to content

Commit 181f974

Browse files
author
Samson Gebre
committed
style: format print statements for better readability and consistency
1 parent d24eee2 commit 181f974

6 files changed

Lines changed: 19 additions & 17 deletions

File tree

examples/advanced/walkthrough.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ def main():
355355
)
356356
result = batch.execute()
357357
batch_ids = list(result.created_ids)
358-
print(f"[OK] Batch create: {len(result.succeeded)} operations in one HTTP request, {len(batch_ids)} records created")
358+
print(
359+
f"[OK] Batch create: {len(result.succeeded)} operations in one HTTP request, {len(batch_ids)} records created"
360+
)
359361

360362
# Batch get: read both records in a single request
361363
log_call("client.batch.new() + batch.records.get(...) x2 + batch.execute()")

examples/basic/functional_testing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,13 @@ def test_batch_all_operations(client: DataverseClient, table_info: Dict[str, Any
393393
print(f" [{i}] FAILED {resp.status_code}: {resp.error_message}")
394394
continue
395395
if i == 0 and resp.data:
396-
print(f" records.get → name='{resp.data.get(f'{attr_prefix}_name')}', count={resp.data.get(f'{attr_prefix}_count')}")
396+
print(
397+
f" records.get → name='{resp.data.get(f'{attr_prefix}_name')}', count={resp.data.get(f'{attr_prefix}_count')}"
398+
)
397399
elif i == 1 and resp.data:
398-
print(f" tables.get → LogicalName='{resp.data.get('LogicalName')}', EntitySet='{resp.data.get('EntitySetName')}'")
400+
print(
401+
f" tables.get → LogicalName='{resp.data.get('LogicalName')}', EntitySet='{resp.data.get('EntitySetName')}'"
402+
)
399403
elif i == 2 and resp.data:
400404
print(f" tables.list → {len(resp.data.get('value', []))} tables returned")
401405
elif i == 3 and resp.data:

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,8 +1735,7 @@ def _build_upsert_multiple(
17351735
"""Build an UpsertMultiple POST request without sending it."""
17361736
if len(alternate_keys) != len(records):
17371737
raise ValidationError(
1738-
f"alternate_keys and records must have the same length "
1739-
f"({len(alternate_keys)} != {len(records)})",
1738+
f"alternate_keys and records must have the same length " f"({len(alternate_keys)} != {len(records)})",
17401739
subcode="upsert_length_mismatch",
17411740
)
17421741
logical_name = table.lower()

src/PowerPlatform/Dataverse/operations/batch.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ def upsert(
283283
for i in items:
284284
if isinstance(i, UpsertItem):
285285
normalized.append(i)
286-
elif (
287-
isinstance(i, dict)
288-
and isinstance(i.get("alternate_key"), dict)
289-
and isinstance(i.get("record"), dict)
290-
):
286+
elif isinstance(i, dict) and isinstance(i.get("alternate_key"), dict) and isinstance(i.get("record"), dict):
291287
normalized.append(UpsertItem(alternate_key=i["alternate_key"], record=i["record"]))
292288
else:
293289
raise ValidationError(

tests/unit/data/test_batch_serialization.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,13 @@ def test_upsert_multiple_items_all_normalised(self):
448448
from PowerPlatform.Dataverse.operations.batch import BatchRecordOperations
449449

450450
rec_ops, batch = self._make_batch()
451-
rec_ops.upsert("account", [
452-
UpsertItem(alternate_key={"accountnumber": "A"}, record={"name": "Alpha"}),
453-
UpsertItem(alternate_key={"accountnumber": "B"}, record={"name": "Beta"}),
454-
])
451+
rec_ops.upsert(
452+
"account",
453+
[
454+
UpsertItem(alternate_key={"accountnumber": "A"}, record={"name": "Alpha"}),
455+
UpsertItem(alternate_key={"accountnumber": "B"}, record={"name": "Beta"}),
456+
],
457+
)
455458

456459
intent = batch._items[0]
457460
self.assertEqual(len(intent.items), 2)

tests/unit/data/test_odata_internal.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ def test_conflicting_key_field_raises(self):
410410
def test_mismatched_lengths_raises(self):
411411
"""Raises when alternate_keys and records lengths differ."""
412412
with self.assertRaises(Exception):
413-
self.od._build_upsert_multiple(
414-
"accounts", "account", [{"accountnumber": "ACC-001"}], []
415-
)
413+
self.od._build_upsert_multiple("accounts", "account", [{"accountnumber": "ACC-001"}], [])
416414

417415
def test_url_contains_upsert_multiple_action(self):
418416
"""POST URL targets the UpsertMultiple bound action."""

0 commit comments

Comments
 (0)