From 016a01cece4243c97bca00dc3d6ace0afa5b7c06 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Wed, 8 Jan 2025 15:26:07 +0100 Subject: [PATCH] Ruff --- favro_sync/favro_client.py | 34 +++++++++++++++++++++++++--------- favro_sync/favro_data_model.py | 3 ++- favro_sync/favro_fuse.py | 9 ++++++--- favro_sync/favro_markdown.py | 2 +- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/favro_sync/favro_client.py b/favro_sync/favro_client.py index 4614461..a82a512 100644 --- a/favro_sync/favro_client.py +++ b/favro_sync/favro_client.py @@ -4,11 +4,10 @@ Implements methods for interacting with the [Favro API](https://favro.com/devel """ import dataclasses -from typing import Any -import requests_cache import datetime from collections.abc import Iterator from logging import getLogger +from typing import Any import requests import requests_util @@ -112,16 +111,24 @@ class FavroClient: # Setup caching requests_util.setup_limiter( - self.session, URL_API_ROOT, datetime.timedelta(days=7), + self.session, + URL_API_ROOT, + datetime.timedelta(days=7), ) requests_util.setup_limiter( - self.session, URL_GET_CARDS, datetime.timedelta(minutes=10), + self.session, + URL_GET_CARDS, + datetime.timedelta(minutes=10), ) requests_util.setup_limiter( - self.session, URL_GET_TASKS, datetime.timedelta(minutes=10), + self.session, + URL_GET_TASKS, + datetime.timedelta(minutes=10), ) requests_util.setup_limiter( - self.session, URL_GET_CUSTOM_FIELD, datetime.timedelta(days=30), + self.session, + URL_GET_CUSTOM_FIELD, + datetime.timedelta(days=30), ) def check_logged_in(self) -> None: @@ -137,9 +144,16 @@ class FavroClient: collection_id: CollectionId | None = None, todo_list=False, ) -> Iterator[Card]: - logger.info('Getting cards: seq_id=%s, collection_id=%s, todo_list=%s', seq_id, collection_id, todo_list) + logger.info( + 'Getting cards: seq_id=%s, collection_id=%s, todo_list=%s', + seq_id, + collection_id, + todo_list, + ) request = self._get_cards_request( - seq_id=seq_id, todo_list=todo_list, collection_id=collection_id, + seq_id=seq_id, + todo_list=todo_list, + collection_id=collection_id, ) for card in self._get_paginated(request, Card.from_json): self.card_cache.add_card(card) @@ -269,7 +283,9 @@ class FavroClient: return self.update_card_contents_locally(card_id, card_contents) def _get_paginated( - self, base_request: requests.Request, entity_from_json, + self, + base_request: requests.Request, + entity_from_json, ) -> Iterator: page = 0 request_id = None diff --git a/favro_sync/favro_data_model.py b/favro_sync/favro_data_model.py index f06505b..761dbc0 100644 --- a/favro_sync/favro_data_model.py +++ b/favro_sync/favro_data_model.py @@ -164,7 +164,8 @@ class CustomFieldInfo: custom_field_items: list[CustomFieldItem] def get_field_item( - self, field_item_id: CustomFieldItemId, + self, + field_item_id: CustomFieldItemId, ) -> CustomFieldItem | None: for item in self.custom_field_items: if item.custom_field_item_id == field_item_id: diff --git a/favro_sync/favro_fuse.py b/favro_sync/favro_fuse.py index c2d8a06..9bf4205 100644 --- a/favro_sync/favro_fuse.py +++ b/favro_sync/favro_fuse.py @@ -34,7 +34,8 @@ CARD_FILENAME_REGEX = r'^PAR\-(\d+)\.md$' def to_custom_field_value( - custom_field: CustomField, field_def: CustomFieldInfo, + custom_field: CustomField, + field_def: CustomFieldInfo, ) -> str | None: value: CustomFieldItemId | list[CustomFieldItemId] = custom_field.value if field_def.type in {'Single select', 'Multiple select'}: @@ -154,12 +155,14 @@ class CardFileSystemItem(FileSystemItem): def path_to_file_system_item( - path_str: str, path_components: list[type[FileSystemItem]], + path_str: str, + path_components: list[type[FileSystemItem]], ) -> FileSystemItem | None: path = re.findall(r'[^/]+', path_str) component = path_components[len(path)] return component.from_path_segment(path[-1] if path else None) + FAST_GETATTR = True @@ -233,7 +236,7 @@ class FavroFuse(fuse.Fuse): elif isinstance(file_system_item, CollectionFileSystemItem): if not self._is_allowed_collection(file_system_item): - return # Yield nothing + return # Yield nothing # TODO: move into own function for collection in self.favro_client.get_collections(): diff --git a/favro_sync/favro_markdown.py b/favro_sync/favro_markdown.py index d80f1fa..b18a9e5 100644 --- a/favro_sync/favro_markdown.py +++ b/favro_sync/favro_markdown.py @@ -1,7 +1,7 @@ import dataclasses import datetime -import re import logging +import re import frontmatter import marko