Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ repos:
rev: v1.20.2
hooks:
- id: mypy
additional_dependencies: [aiopathlib, asyncio-for-ynab, rich>=14]
additional_dependencies: [aiopathlib, asyncio-for-ynab, rich>=12]
language_version: python3.12
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ install_requires =
aiosqlite
asyncio-for-ynab
fasteners
rich>=14
rich>=12
tenacity
python_requires = >=3.12

Expand Down
27 changes: 26 additions & 1 deletion sqlite_export_for_ynab/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from asyncio_for_ynab import TransactionDetail
from asyncio_for_ynab import TransactionsApi
from rich.progress import BarColumn
from rich.progress import MofNCompleteColumn
from rich.progress import Progress
from rich.progress import TaskID
from rich.progress import TextColumn
Expand All @@ -50,6 +49,32 @@
from collections.abc import Iterator
from collections.abc import Sequence

try:
from rich.progress import MofNCompleteColumn
# https://github.com/benleb/surepy/issues/240
except ImportError: # pragma: no cover
from rich.progress import ProgressColumn
from rich.progress import Task
from rich.text import Text

if TYPE_CHECKING:
from rich.table import Column

class MofNCompleteColumn(ProgressColumn): # type:ignore[no-redef]
def __init__(self, separator: str = "/", table_column: Column | None = None):
self.separator = separator
super().__init__(table_column=table_column)

def render(self, task: Task) -> Text:
"""Show completed/total."""
completed = int(task.completed)
total = int(task.total) if task.total is not None else "?"
total_width = len(str(total))
return Text(
f"{completed:{total_width}d}{self.separator}{total}",
style="progress.download",
)


_EntryTable = (
Literal["accounts"]
Expand Down
Loading