Ruff
This commit is contained in:
parent
6201fc9c8c
commit
016a01cece
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import dataclasses
|
||||
import datetime
|
||||
import re
|
||||
import logging
|
||||
import re
|
||||
|
||||
import frontmatter
|
||||
import marko
|
||||
|
|
Loading…
Reference in New Issue
Block a user