style: say which lint rules this repo keeps, then keep them

`[tool.ruff]` set a line length and a target version and nothing else, so which
rules ran depended on the installed ruff's defaults — fine while nobody ran it,
not fine for a CI job that can turn a push red because a tool changed its mind.

The set is named explicitly (E, F, I, UP, SIM, B, RUF) with three ignores that
are each a real decision rather than a shrug: B008, because FastAPI's whole
dependency idiom is a call in a default argument; E501, because wrapping prose
is a formatter's business; and RUF001, because the reports and the bot speak
Russian and "ambiguous character" is the wrong complaint about a string the
user is meant to read.

The 73 findings that remained are fixed — mostly `datetime.timezone.utc` →
`datetime.UTC`, `typing.Callable` → `collections.abc.Callable`, import order,
and unused `noqa` markers — plus seven by hand: `contextlib.suppress` for two
try/except/pass pairs, unpacking instead of list concatenation, one negated
return.

`ruff format` is deliberately *not* adopted: it would reformat 51 files, and
some of the layout here is hand-set (the comment tables, the DNS wire-format
structs) in ways a formatter flattens.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
timka123andClaude Opus 5 committed 2026-10-22 17:28:57 +03:00
1 parent 5facf41f10
commit ec7eedbc66
28 files changed
+84 -68

No files matched your search

+3 -3
View File
@@ -8,7 +8,7 @@ day so a re-send shows the same numbers.
from __future__ import annotations
from datetime import date, datetime, timezone
from datetime import UTC, date, datetime
from typing import Any
from sqlalchemy import (
@@ -30,7 +30,7 @@ from app.db import Base
def utcnow() -> datetime:
return datetime.now(timezone.utc)
return datetime.now(UTC)
class SettingsRow(Base):
@@ -80,7 +80,7 @@ class PomodoroSession(Base):
note: Mapped[str | None] = mapped_column(Text)
abandon_reason: Mapped[str | None] = mapped_column(Text)
block_events: Mapped[list["BlockEvent"]] = relationship(back_populates="session")
block_events: Mapped[list[BlockEvent]] = relationship(back_populates="session")
@property
def is_work(self) -> bool:
+2 -1
View File
@@ -8,9 +8,10 @@ the Telegram message at once.
from __future__ import annotations
import logging
from collections.abc import Callable
from dataclasses import dataclass
from datetime import date
from typing import Any, Callable
from typing import Any
Metrics = dict[str, Any]
Context = dict[str, Any]
+5 -5
View File
@@ -17,7 +17,7 @@ import hashlib
import hmac
import secrets
import time
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from typing import Any
from sqlalchemy import delete
@@ -84,7 +84,7 @@ def create_session(session: Session, method: str, session_days: int) -> AuthSess
row = AuthSession(
token=secrets.token_urlsafe(32),
method=method,
expires_at=datetime.now(timezone.utc) + timedelta(days=session_days),
expires_at=datetime.now(UTC) + timedelta(days=session_days),
)
session.add(row)
session.commit()
@@ -93,7 +93,7 @@ def create_session(session: Session, method: str, session_days: int) -> AuthSess
def _aware(dt: datetime) -> datetime:
"""SQLite drops the tzinfo it was stored with; Postgres does not."""
return dt if dt.tzinfo else dt.replace(tzinfo=timezone.utc)
return dt if dt.tzinfo else dt.replace(tzinfo=UTC)
def valid_session(session: Session, token: str | None) -> AuthSession | None:
@@ -102,7 +102,7 @@ def valid_session(session: Session, token: str | None) -> AuthSession | None:
row = session.get(AuthSession, token)
if row is None:
return None
if _aware(row.expires_at) < datetime.now(timezone.utc):
if _aware(row.expires_at) < datetime.now(UTC):
session.delete(row)
session.commit()
return None
@@ -117,7 +117,7 @@ def delete_session(session: Session, token: str | None) -> None:
def _prune_expired(session: Session) -> None:
session.execute(delete(AuthSession).where(AuthSession.expires_at < datetime.now(timezone.utc)))
session.execute(delete(AuthSession).where(AuthSession.expires_at < datetime.now(UTC)))
# --------------------------------------------------------------------------
+2 -1
View File
@@ -13,7 +13,8 @@ Three jobs:
from __future__ import annotations
import threading
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from sqlalchemy.orm import Session
+2 -1
View File
@@ -14,8 +14,9 @@ is recorded as closed today.
from __future__ import annotations
import logging
from collections.abc import Iterable
from datetime import date
from typing import Any, Iterable
from typing import Any
from uuid import uuid4
from sqlalchemy import select
+2 -1
View File
@@ -10,7 +10,8 @@ from __future__ import annotations
import logging
import threading
import time as time_module
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import httpx
+1 -1
View File
@@ -51,7 +51,7 @@ class SourceResult:
error: str | None = None
@classmethod
def failed(cls, source: str, error: str) -> "SourceResult":
def failed(cls, source: str, error: str) -> SourceResult:
return cls(source=source, items=[], ok=False, error=error)
+2 -1
View File
@@ -11,8 +11,9 @@ still things you can spend a pomodoro on.
from __future__ import annotations
from collections.abc import Iterator
from datetime import date
from typing import Any, Iterator
from typing import Any
import httpx
+2 -1
View File
@@ -13,8 +13,9 @@ notices it has left the "open issues" query. One owner per task.
from __future__ import annotations
import re
from collections.abc import Iterator
from datetime import date
from typing import Any, Iterator
from typing import Any
import httpx
+2 -1
View File
@@ -8,8 +8,9 @@ empty task list.
from __future__ import annotations
import logging
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Callable
from typing import Any
from app.settings_schema import AppSettings
from app.sources.base import SourceError, SourceResult, TodoItem
+2 -1
View File
@@ -9,8 +9,9 @@ for people who want the narrower list.
from __future__ import annotations
from collections.abc import Iterator
from datetime import date
from typing import Any, Iterator
from typing import Any
import httpx
+5 -5
View File
@@ -7,7 +7,7 @@ for" — here.
from __future__ import annotations
from datetime import date, datetime, time, timedelta, timezone
from datetime import UTC, date, datetime, time, timedelta
from zoneinfo import ZoneInfo
@@ -19,7 +19,7 @@ def tz(name: str) -> ZoneInfo:
def now_utc() -> datetime:
return datetime.now(timezone.utc)
return datetime.now(UTC)
def ensure_utc(moment: datetime | None) -> datetime | None:
@@ -31,12 +31,12 @@ def ensure_utc(moment: datetime | None) -> datetime | None:
"""
if moment is None:
return None
return moment if moment.tzinfo is not None else moment.replace(tzinfo=timezone.utc)
return moment if moment.tzinfo is not None else moment.replace(tzinfo=UTC)
def to_local(moment: datetime, tz_name: str) -> datetime:
if moment.tzinfo is None:
moment = moment.replace(tzinfo=timezone.utc)
moment = moment.replace(tzinfo=UTC)
return moment.astimezone(tz(tz_name))
@@ -54,7 +54,7 @@ def day_bounds_utc(day: date, tz_name: str) -> tuple[datetime, datetime]:
zone = tz(tz_name)
start = datetime.combine(day, time.min, tzinfo=zone)
end = start + timedelta(days=1)
return start.astimezone(timezone.utc), end.astimezone(timezone.utc)
return start.astimezone(UTC), end.astimezone(UTC)
def in_window(moment: time, start: time, end: time) -> bool: