Skip to content

Commit 533d6f6

Browse files
zhaodongwang-msftMax Wang
andauthored
black formatting for examples (#101)
Co-authored-by: Max Wang <zhaodongwang@microsoft.com>
1 parent a28a1a8 commit 533d6f6

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

examples/advanced/file_upload.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def log(call: str):
6868
_FILE_HASH_CACHE = {}
6969
ATTRIBUTE_VISIBILITY_DELAYS = (0, 3, 10, 20, 35, 50, 70, 90, 120)
7070

71+
7172
def file_sha256(path: Path): # returns (hex_digest, size_bytes)
7273
try:
7374
m = _FILE_HASH_CACHE.get(path)
@@ -166,19 +167,15 @@ def backoff(op, *, delays=(0, 2, 5, 10, 20, 20)):
166167
result = op()
167168
if attempts > 1:
168169
retry_count = attempts - 1
169-
print(
170-
f" [INFO] Backoff succeeded after {retry_count} retry(s); waited {total_delay}s total."
171-
)
170+
print(f" [INFO] Backoff succeeded after {retry_count} retry(s); waited {total_delay}s total.")
172171
return result
173172
except Exception as ex: # noqa: BLE001
174173
last = ex
175174
continue
176175
if last:
177176
if attempts:
178177
retry_count = max(attempts - 1, 0)
179-
print(
180-
f" [WARN] Backoff exhausted after {retry_count} retry(s); waited {total_delay}s total."
181-
)
178+
print(f" [WARN] Backoff exhausted after {retry_count} retry(s); waited {total_delay}s total.")
182179
raise last
183180

184181

@@ -337,9 +334,7 @@ def get_dataset_info(file_path: Path):
337334
)
338335
print({"chunk_upload_completed": True})
339336
odata = client._get_odata()
340-
dl_url_chunk = (
341-
f"{odata.api}/{entity_set}({record_id})/{chunk_file_attr_schema.lower()}/$value" # raw entity_set for download
342-
)
337+
dl_url_chunk = f"{odata.api}/{entity_set}({record_id})/{chunk_file_attr_schema.lower()}/$value" # raw entity_set for download
343338
resp_chunk = backoff(lambda: odata._request("get", dl_url_chunk))
344339
content_chunk = resp_chunk.content or b""
345340
import hashlib # noqa: WPS433

examples/advanced/walkthrough.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,15 @@ def backoff(op, *, delays=(0, 2, 5, 10, 20, 20)):
5252
result = op()
5353
if attempts > 1:
5454
retry_count = attempts - 1
55-
print(
56-
f" [INFO] Backoff succeeded after {retry_count} retry(s); waited {total_delay}s total."
57-
)
55+
print(f" [INFO] Backoff succeeded after {retry_count} retry(s); waited {total_delay}s total.")
5856
return result
5957
except Exception as ex: # noqa: BLE001
6058
last = ex
6159
continue
6260
if last:
6361
if attempts:
6462
retry_count = max(attempts - 1, 0)
65-
print(
66-
f" [WARN] Backoff exhausted after {retry_count} retry(s); waited {total_delay}s total."
67-
)
63+
print(f" [WARN] Backoff exhausted after {retry_count} retry(s); waited {total_delay}s total.")
6864
raise last
6965

7066

@@ -339,7 +335,7 @@ def main():
339335
print(f"[OK] Deleted table: {table_name}")
340336
except Exception as ex: # noqa: BLE001
341337
code = getattr(getattr(ex, "response", None), "status_code", None)
342-
if (isinstance(ex, (requests.exceptions.HTTPError, MetadataError)) and code == 404):
338+
if isinstance(ex, (requests.exceptions.HTTPError, MetadataError)) and code == 404:
343339
print(f"[OK] Table removed: {table_name}")
344340
else:
345341
raise

examples/basic/functional_testing.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,16 @@ def wait_for_table_metadata(
9191
odata._entity_set_from_schema_name(table_schema_name)
9292

9393
if attempt > 1:
94-
print(
95-
f" [OK] Table metadata available after {attempt} attempts."
96-
)
94+
print(f" [OK] Table metadata available after {attempt} attempts.")
9795
return info
9896
except Exception:
9997
pass
10098

10199
if attempt < retries:
102-
print(
103-
f" Waiting for table metadata to publish (attempt {attempt}/{retries})..."
104-
)
100+
print(f" Waiting for table metadata to publish (attempt {attempt}/{retries})...")
105101
time.sleep(delay_seconds)
106102

107-
raise RuntimeError(
108-
"Table metadata did not become available in time. Please retry later."
109-
)
103+
raise RuntimeError("Table metadata did not become available in time. Please retry later.")
110104

111105

112106
def ensure_test_table(client: DataverseClient) -> Dict[str, Any]:
@@ -229,9 +223,7 @@ def test_read_record(client: DataverseClient, table_info: Dict[str, Any], record
229223
break
230224
except HttpError as err:
231225
if getattr(err, "status_code", None) == 404 and attempt < retries:
232-
print(
233-
f" Record not queryable yet (attempt {attempt}/{retries}). Retrying in {delay_seconds}s..."
234-
)
226+
print(f" Record not queryable yet (attempt {attempt}/{retries}). Retrying in {delay_seconds}s...")
235227
time.sleep(delay_seconds)
236228
continue
237229
raise
@@ -301,9 +293,7 @@ def test_query_records(client: DataverseClient, table_info: Dict[str, Any]) -> N
301293
break
302294
except HttpError as err:
303295
if getattr(err, "status_code", None) == 404 and attempt < retries:
304-
print(
305-
f" Query retry {attempt}/{retries} after metadata 404 ({err}). Waiting {delay_seconds}s..."
306-
)
296+
print(f" Query retry {attempt}/{retries} after metadata 404 ({err}). Waiting {delay_seconds}s...")
307297
time.sleep(delay_seconds)
308298
continue
309299
raise
@@ -373,9 +363,7 @@ def cleanup_test_data(client: DataverseClient, table_info: Dict[str, Any], recor
373363
print("[OK] Test table deleted successfully (404 reported).")
374364
break
375365
if attempt < retries:
376-
print(
377-
f" Table delete retry {attempt}/{retries} after error ({err}). Waiting {delay_seconds}s..."
378-
)
366+
print(f" Table delete retry {attempt}/{retries} after error ({err}). Waiting {delay_seconds}s...")
379367
time.sleep(delay_seconds)
380368
continue
381369
print(f"[WARN] Failed to delete test table: {err}")

examples/basic/installation_example.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def show_usage_examples():
173173
print("\nUsage Examples")
174174
print("=" * 50)
175175

176-
print(
177-
"""
176+
print("""
178177
Basic Setup:
179178
```python
180179
from PowerPlatform.Dataverse.client import DataverseClient
@@ -244,8 +243,7 @@ def show_usage_examples():
244243
tables = client.list_tables()
245244
print(f"Found {len(tables)} tables")
246245
```
247-
"""
248-
)
246+
""")
249247

250248

251249
def interactive_test():

0 commit comments

Comments
 (0)