Skip to content

chore: make ruff check pass again - #39

Open
Flummy1 wants to merge 3 commits into
devfrom
chore/fix-ruff-mypy-strict
Open

Flummy1 wants to merge 3 commits into
devfrom
chore/fix-ruff-mypy-strict

Conversation

@Flummy1

@Flummy1 Flummy1 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Что изменилось по сравнению с исходной версией PR

Ветка была открыта, когда ruff check, ruff format --check и mypy --strict
падали на всём проекте. С тех пор эта работа приехала на dev со стороны
мейнтейнера: на 0.10.0rc3 mypy --strict чист, а ruff спотыкается ровно
на одном файле.

Поэтому PR ужат до этого остатка. Второй коммит ветки — фикс потери фильтра
транзакций при пагинации (#40) — на dev не приезжал и переехал в
#41, где он лежит
рядом с таким же фиксом для отзывов.

Что осталось

make ci прогоняет ruff check и ruff format --check, и оба падают на
funpaybotengine/types/offers.py:

  • typing_extensions.Self импортируется, но не используется (F401);
  • одна строка не соответствует ruff format.

Диф — 5 строк в одном файле, поведение не меняется.

Проверки

uv run ruff check funpaybotengine tests     # All checks passed!
uv run ruff format --check funpaybotengine tests   # 105 files already formatted
uv run mypy funpaybotengine                 # no issues found
uv run pytest tests                         # 14 passed

🤖 Generated with Claude Code

Flummy1 and others added 2 commits July 16, 2026 12:06
* fix: preserve requested transaction filter across pagination

`TransactionPreviewsBatch.next_batch()` re-derived the filter from `self.filter`,
which is scraped from the response HTML. FunPay omits the hidden `filter` input in
some responses, so `self.filter` became `None` and `self.filter or ''` silently
widened the filter to `TransactionFilter.ALL` — every page after the first returned
the entire transaction feed instead of the requested category.

`TransactionFilter.ALL` is `''` and therefore falsy, so no `or`-based fallback on
this enum can distinguish "no filter" from "unknown filter".

Thread the requested filter through the method context, the same way `GetSales`
threads `order_preview_type`, and let `next_batch()` fail loudly on an unknown
filter instead of defaulting to the widest one — mirroring
`OrderPreviewsBatch.next_batch()`.

- `GetTransactions` now passes `context={'transaction_filter': ...}`.
- `TransactionPreviewsBatch` prefers the requested filter over the scraped one.
- `next_batch()` raises `ValueError` when the filter is unknown.
- `GetTransactionsPage` marks its batch as `ALL` (the balance page is unfiltered).
- `GetTransactions()` no longer fails validation when called without arguments
  (`from_transaction_id` defaulted to `None` against an `int` field).

Adds a regression suite covering the end-to-end path with a response that has no
hidden `filter` input.

* chore: remove pagination filter tests

Requested by maintainer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore: drop pytest config from pyproject

Requested by maintainer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor: stamp transaction filter on the batch instead of the validation context

Passing the requested filter through the pydantic validation context leaked it to
every nested model: pydantic hands the same context object to each nested
`model_validate`, so `header`, `app_data`, every `MoneyValue` and every
`TransactionPreview` saw `transaction_filter`, not just the batch it belongs to.

Stamp the filter directly on the batch in the building method instead:

- `GetTransactions.transform_result` sets `batch.filter` to the requested filter.
- `GetTransactionsPage.transform_result` marks its nested batch as `ALL`.
- Drop the context-reading `model_post_init` from `TransactionPreviewsBatch`; the
  HTML-scraped value stays as a fallback for hand-built objects.

The validation context now carries only `bot`. Filter propagation is verified
end-to-end against a response with no hidden `filter` input.

* small improvements

* moved filter logic to method init

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: qvvonk <qvvonk@gmail.com>
Scope reduced to what dev still needs: the `mypy --strict` work this branch
carried has since landed on dev, and the transaction-filter fix moved to the
reviews/transactions pagination PR. What is left is the one file that still
breaks `ruff check` and `ruff format --check`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Flummy1 Flummy1 changed the title chore: fix ruff and mypy strict checks chore: make ruff check pass again Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant