Skip to content

Commit c073d55

Browse files
just1602WhyNotHugo
authored andcommitted
Don't allow load_status to return None
1 parent 3611e7d commit c073d55

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

vdirsyncer/cli/discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def collections_for_pair(
5757
cache_key = _get_collections_cache_key(pair)
5858
if from_cache:
5959
rv = load_status(status_path, pair.name, data_type="collections")
60-
if rv and rv.get("cache_key", None) == cache_key:
60+
if rv.get("cache_key", None) == cache_key:
6161
return list(
6262
_expand_collections_cache(
6363
rv["collections"], pair.config_a, pair.config_b

vdirsyncer/cli/tasks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ async def metasync_collection(collection, general, *, connector: aiohttp.TCPConn
142142
try:
143143
cli_logger.info(f"Metasyncing {status_name}")
144144

145-
status = (
146-
load_status(
147-
general["status_path"], pair.name, collection.name, data_type="metadata"
148-
)
149-
or {}
145+
status = load_status(
146+
general["status_path"],
147+
pair.name,
148+
collection.name,
149+
data_type="metadata",
150150
)
151151

152152
a = await storage_instance_from_config(collection.config_a, connector=connector)

vdirsyncer/cli/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import os
88
import sys
9+
from typing import Any
910

1011
import aiohttp
1112
import click
@@ -186,11 +187,11 @@ def load_status(
186187
base_path: str,
187188
pair: str,
188189
collection: str | None = None,
189-
data_type: str | None = None
190-
) -> dict | None:
190+
data_type: str | None = None,
191+
) -> dict[str, Any]:
191192
path = get_status_path(base_path, pair, collection, data_type)
192193
if not os.path.exists(path):
193-
return None
194+
return {}
194195
assert_permissions(path, STATUS_PERMISSIONS)
195196

196197
with open(path) as f:

0 commit comments

Comments
 (0)