Skip to content

Commit f6a67c9

Browse files
committed
Fix style and add Optional type
1 parent dd397ac commit f6a67c9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

examples/static-credentials/example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ydb
22

3+
34
def test_driver_works(driver: ydb.Driver):
45
"""Tests the functionality of the YDB driver.
56
@@ -16,6 +17,7 @@ def test_driver_works(driver: ydb.Driver):
1617
result = pool.execute_with_retries("SELECT 1 as cnt")
1718
assert result[0].rows[0].cnt == 1
1819

20+
1921
def auth_with_static_credentials(endpoint: str, database: str, user: str, password: str, ca_path: str):
2022
"""Authenticate using static credentials.
2123
@@ -32,10 +34,10 @@ def auth_with_static_credentials(endpoint: str, database: str, user: str, passwo
3234
"""
3335

3436
driver_config = ydb.DriverConfig(
35-
endpoint = endpoint,
36-
database = database,
37-
credentials = ydb.StaticCredentials.from_user_password(user, password),
38-
root_certificates = ydb.auth_helpers.load_ydb_root_certificate(ca_path)
37+
endpoint=endpoint,
38+
database=database,
39+
credentials=ydb.StaticCredentials.from_user_password(user, password),
40+
root_certificates=ydb.load_ydb_root_certificate(ca_path)
3941
)
4042

4143
with ydb.Driver(driver_config=driver_config) as driver:

ydb/auth_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# -*- coding: utf-8 -*-
22
import os
3+
from typing import Optional
34

45

56
def read_bytes(f):
67
with open(f, "rb") as fr:
78
return fr.read()
89

910

10-
def load_ydb_root_certificate(path:str = None):
11+
def load_ydb_root_certificate(path: Optional[str] = None):
1112
if path is not None and os.path.exists(path):
1213
return read_bytes(path)
1314
return None

0 commit comments

Comments
 (0)