Skip to content

chore: fix ruff and mypy strict checks#39

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

chore: fix ruff and mypy strict checks#39
Flummy1 wants to merge 2 commits into
devfrom
chore/fix-ruff-mypy-strict

Conversation

@Flummy1

@Flummy1 Flummy1 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Что изменено

  • Исправлены все ошибки ruff check.
  • Проект приведён к форматированию ruff format.
  • Исправлены ошибки mypy --strict без отключения strict-режима.
  • Уточнил типы при разборе JSON-ответов.
  • Исправил типизацию потока событий runner.
  • Убрал bare except в refund-методе.
  • Добавил .gitattributes, чтобы зафиксировать LF для текстовых файлов проекта

Проверки

  • uv run ruff check .
  • uv run ruff format --check .
  • uv run mypy funpaybotengine

Все проверки проходят.

Примечание

Тесты не запускались как успешный gate, потому что в репозитории нет директории tests; pytest -q завершается с no tests ran.

* 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>
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