From f194bb0a4c52c3620071429590377c1e3bec2ae9 Mon Sep 17 00:00:00 2001 From: Justin ! Date: Wed, 23 Aug 2023 00:03:48 -0400 Subject: [PATCH] Do not allow `None` value if we assert they're not None on the next line This change imply changing the `save_status` parameters order. If you don't like that, I can drop this commit. --- vdirsyncer/cli/discover.py | 4 ++-- vdirsyncer/cli/tasks.py | 6 +++--- vdirsyncer/cli/utils.py | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index 2ddb0a3..9de6177 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -108,8 +108,8 @@ async def collections_for_pair( await _sanity_check_collections(rv, connector=connector) save_status( - status_path, - pair.name, + base_path=status_path, + pair=pair.name, data_type="collections", data={ "collections": list( diff --git a/vdirsyncer/cli/tasks.py b/vdirsyncer/cli/tasks.py index 84f8290..0207cb1 100644 --- a/vdirsyncer/cli/tasks.py +++ b/vdirsyncer/cli/tasks.py @@ -164,9 +164,9 @@ async def metasync_collection(collection, general, *, connector: aiohttp.TCPConn raise JobFailed save_status( - general["status_path"], - pair.name, - collection.name, + base_path=general["status_path"], + pair=pair.name, data_type="metadata", data=status, + collection=collection.name, ) diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index 9f5992f..247a748 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -242,12 +242,10 @@ def manage_sync_status(base_path: str, pair_name: str, collection_name: str): def save_status( base_path: str, pair: str, + data_type: str, + data: dict[str, Any], collection: str | None = None, - data_type: str | None = None, - data: dict | None = None, ) -> None: - assert data_type is not None - assert data is not None status_name = get_status_name(pair, collection) path = expand_path(os.path.join(base_path, status_name)) + "." + data_type prepare_status_path(path)