chore: fix ruff and mypy strict checks#39
Open
Flummy1 wants to merge 2 commits into
Open
Conversation
* 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что изменено
ruff check.ruff format.mypy --strictбез отключения strict-режима.exceptв refund-методе..gitattributes, чтобы зафиксировать LF для текстовых файлов проектаПроверки
uv run ruff check .uv run ruff format --check .uv run mypy funpaybotengineВсе проверки проходят.
Примечание
Тесты не запускались как успешный gate, потому что в репозитории нет директории
tests;pytest -qзавершается сno tests ran.