Skip to content

Commit 28ce3cb

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b24d208 commit 28ce3cb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

python/populse_db/engine/sqlite.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def close(self, rollback=False):
9393
else:
9494
self.sqlite.commit()
9595
if self.echo_sql:
96-
print(f"Disconnect from database (rollback={rollback})", file=self.echo_sql, flush=True)
96+
print(
97+
f"Disconnect from database (rollback={rollback})",
98+
file=self.echo_sql,
99+
flush=True,
100+
)
97101
self.sqlite.close()
98102

99103
def has_collection(self, name):

python/populse_db/server.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,21 @@ def create_server():
4545
storage_api = StorageFileAPI(database_file, create=create, secret=secret)
4646
lock = threading.Lock()
4747

48-
4948
@asynccontextmanager
5049
async def lifespan(app: FastAPI):
5150
cnx = sqlite3.connect(database_file, isolation_level="EXCLUSIVE")
5251
try:
5352
if verbose:
5453
print("Storing external URL:", url)
55-
rows = cnx.execute(f"SELECT _json FROM [{populse_db_table}] WHERE category='server' AND key='url'").fetchall()
54+
rows = cnx.execute(
55+
f"SELECT _json FROM [{populse_db_table}] WHERE category='server' AND key='url'"
56+
).fetchall()
5657
if rows:
5758
existing_url = rows[0][0]
5859
if existing_url != url:
59-
raise RuntimeError(f"Cannot start server with URL {url} because another server already exists with URL {existing_url}")
60+
raise RuntimeError(
61+
f"Cannot start server with URL {url} because another server already exists with URL {existing_url}"
62+
)
6063
else:
6164
cnx.execute(
6265
f"INSERT INTO [{populse_db_table}] (category, key, _json) VALUES ('server','url',?)",
@@ -116,7 +119,6 @@ async def catch_exceptions_middleware(request: Request, call_next):
116119

117120
@app.get("/access_token")
118121
def access_token(write: query_bool, challenge: query_str):
119-
120122
access_token = storage_api.access_token(write=write, challenge=challenge)
121123
return access_token
122124

python/populse_db/test/test_storage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ def test_storage_server():
481481
tmp_path = tmp.name
482482
tmp.close()
483483
cmd = [sys.executable, "-m", "populse_db.server", "-v", tmp_path]
484-
server = subprocess.Popen(cmd, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
484+
server = subprocess.Popen(
485+
cmd, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL
486+
)
485487

486488
try:
487489
store = Storage(f"server:{tmp_path}", echo_sql=sys.stdout)

0 commit comments

Comments
 (0)