Skip to content

Commit 65236b9

Browse files
authored
Bump ruff from 0.5.7 to 0.11.7 (#23)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.5.7 to 0.11.7. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/releases">ruff's releases</a>.</em></p> <blockquote> <h2>0.11.7</h2> <h2>Release Notes</h2> <h3>Preview features</h3> <ul> <li>[<code>airflow</code>] Apply auto fixes to cases where the names have changed in Airflow 3 (<code>AIR301</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17355">#17355</a>)</li> <li>[<code>perflint</code>] Implement fix for <code>manual-dict-comprehension</code> (<code>PERF403</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/16719">#16719</a>)</li> <li>[syntax-errors] Make duplicate parameter names a semantic error (<a href="https://redirect.github.com/astral-sh/ruff/pull/17131">#17131</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>[<code>airflow</code>] Fix typos in provider package names (<code>AIR302</code>, <code>AIR312</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17574">#17574</a>)</li> <li>[<code>flake8-type-checking</code>] Visit keyword arguments in checks involving <code>typing.cast</code>/<code>typing.NewType</code> arguments (<a href="https://redirect.github.com/astral-sh/ruff/pull/17538">#17538</a>)</li> <li>[<code>pyupgrade</code>] Preserve parenthesis when fixing native literals containing newlines (<code>UP018</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17220">#17220</a>)</li> <li>[<code>refurb</code>] Mark the <code>FURB161</code> fix unsafe except for integers and booleans (<a href="https://redirect.github.com/astral-sh/ruff/pull/17240">#17240</a>)</li> </ul> <h3>Rule changes</h3> <ul> <li>[<code>perflint</code>] Allow list function calls to be replaced with a comprehension (<code>PERF401</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17519">#17519</a>)</li> <li>[<code>pycodestyle</code>] Auto-fix redundant boolean comparison (<code>E712</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17090">#17090</a>)</li> <li>[<code>pylint</code>] make fix unsafe if delete comments (<code>PLR1730</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17459">#17459</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>Add fix safety sections to docs for several rules (<a href="https://redirect.github.com/astral-sh/ruff/pull/17410">#17410</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17440">#17440</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17441">#17441</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17443">#17443</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17444">#17444</a>)</li> </ul> <h2>Contributors</h2> <ul> <li><a href="https://github.com/AlexWaygood"><code>@​AlexWaygood</code></a></li> <li><a href="https://github.com/BurntSushi"><code>@​BurntSushi</code></a></li> <li><a href="https://github.com/Daverball"><code>@​Daverball</code></a></li> <li><a href="https://github.com/Gankra"><code>@​Gankra</code></a></li> <li><a href="https://github.com/Glyphack"><code>@​Glyphack</code></a></li> <li><a href="https://github.com/Kalmaegi"><code>@​Kalmaegi</code></a></li> <li><a href="https://github.com/Lee-W"><code>@​Lee-W</code></a></li> <li><a href="https://github.com/MatthewMckee4"><code>@​MatthewMckee4</code></a></li> <li><a href="https://github.com/MichaReiser"><code>@​MichaReiser</code></a></li> <li><a href="https://github.com/VascoSch92"><code>@​VascoSch92</code></a></li> <li><a href="https://github.com/camper42"><code>@​camper42</code></a></li> <li><a href="https://github.com/carljm"><code>@​carljm</code></a></li> <li><a href="https://github.com/dcreager"><code>@​dcreager</code></a></li> <li><a href="https://github.com/dhruvmanila"><code>@​dhruvmanila</code></a></li> <li><a href="https://github.com/ericmarkmartin"><code>@​ericmarkmartin</code></a></li> <li><a href="https://github.com/jnooree"><code>@​jnooree</code></a></li> <li><a href="https://github.com/knavdeep152002"><code>@​knavdeep152002</code></a></li> <li><a href="https://github.com/maxmynter"><code>@​maxmynter</code></a></li> <li><a href="https://github.com/mtshiba"><code>@​mtshiba</code></a></li> <li><a href="https://github.com/ntBre"><code>@​ntBre</code></a></li> <li><a href="https://github.com/renovate"><code>@​renovate</code></a></li> <li><a href="https://github.com/sharkdp"><code>@​sharkdp</code></a></li> <li><a href="https://github.com/w0nder1ng"><code>@​w0nder1ng</code></a></li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's changelog</a>.</em></p> <blockquote> <h2>0.11.7</h2> <h3>Preview features</h3> <ul> <li>[<code>airflow</code>] Apply auto fixes to cases where the names have changed in Airflow 3 (<code>AIR301</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17355">#17355</a>)</li> <li>[<code>perflint</code>] Implement fix for <code>manual-dict-comprehension</code> (<code>PERF403</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/16719">#16719</a>)</li> <li>[syntax-errors] Make duplicate parameter names a semantic error (<a href="https://redirect.github.com/astral-sh/ruff/pull/17131">#17131</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>[<code>airflow</code>] Fix typos in provider package names (<code>AIR302</code>, <code>AIR312</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17574">#17574</a>)</li> <li>[<code>flake8-type-checking</code>] Visit keyword arguments in checks involving <code>typing.cast</code>/<code>typing.NewType</code> arguments (<a href="https://redirect.github.com/astral-sh/ruff/pull/17538">#17538</a>)</li> <li>[<code>pyupgrade</code>] Preserve parenthesis when fixing native literals containing newlines (<code>UP018</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17220">#17220</a>)</li> <li>[<code>refurb</code>] Mark the <code>FURB161</code> fix unsafe except for integers and booleans (<a href="https://redirect.github.com/astral-sh/ruff/pull/17240">#17240</a>)</li> </ul> <h3>Rule changes</h3> <ul> <li>[<code>perflint</code>] Allow list function calls to be replaced with a comprehension (<code>PERF401</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17519">#17519</a>)</li> <li>[<code>pycodestyle</code>] Auto-fix redundant boolean comparison (<code>E712</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17090">#17090</a>)</li> <li>[<code>pylint</code>] make fix unsafe if delete comments (<code>PLR1730</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17459">#17459</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>Add fix safety sections to docs for several rules (<a href="https://redirect.github.com/astral-sh/ruff/pull/17410">#17410</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17440">#17440</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17441">#17441</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17443">#17443</a>,<a href="https://redirect.github.com/astral-sh/ruff/pull/17444">#17444</a>)</li> </ul> <h2>0.11.6</h2> <h3>Preview features</h3> <ul> <li>Avoid adding whitespace to the end of a docstring after an escaped quote (<a href="https://redirect.github.com/astral-sh/ruff/pull/17216">#17216</a>)</li> <li>[<code>airflow</code>] Extract <code>AIR311</code> from <code>AIR301</code> rules (<code>AIR301</code>, <code>AIR311</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17310">#17310</a>, <a href="https://redirect.github.com/astral-sh/ruff/pull/17422">#17422</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>Raise syntax error when <code>\</code> is at end of file (<a href="https://redirect.github.com/astral-sh/ruff/pull/17409">#17409</a>)</li> </ul> <h2>0.11.5</h2> <h3>Preview features</h3> <ul> <li>[<code>airflow</code>] Add missing <code>AIR302</code> attribute check (<a href="https://redirect.github.com/astral-sh/ruff/pull/17115">#17115</a>)</li> <li>[<code>airflow</code>] Expand module path check to individual symbols (<code>AIR302</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17278">#17278</a>)</li> <li>[<code>airflow</code>] Extract <code>AIR312</code> from <code>AIR302</code> rules (<code>AIR302</code>, <code>AIR312</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/17152">#17152</a>)</li> <li>[<code>airflow</code>] Update oudated <code>AIR301</code>, <code>AIR302</code> rules (<a href="https://redirect.github.com/astral-sh/ruff/pull/17123">#17123</a>)</li> <li>[syntax-errors] Async comprehension in sync comprehension (<a href="https://redirect.github.com/astral-sh/ruff/pull/17177">#17177</a>)</li> <li>[syntax-errors] Check annotations in annotated assignments (<a href="https://redirect.github.com/astral-sh/ruff/pull/17283">#17283</a>)</li> <li>[syntax-errors] Extend annotation checks to <code>await</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/17282">#17282</a>)</li> </ul> <h3>Bug fixes</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/astral-sh/ruff/commit/f7b48510b58026f73c153ecb57720754365ba92e"><code>f7b4851</code></a> Bump 0.11.7 (<a href="https://redirect.github.com/astral-sh/ruff/issues/17613">#17613</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/99370647615c853e1fdd5bebb3fdff221a826d15"><code>9937064</code></a> [red-knot] Use iterative approach to collect overloads (<a href="https://redirect.github.com/astral-sh/ruff/issues/17607">#17607</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/8d2c79276d167fcfcf9143a2bc1b328bb9d0f876"><code>8d2c792</code></a> red_knot_python_semantic: avoid Rust's screaming snake case convention in mdtest</li> <li><a href="https://github.com/astral-sh/ruff/commit/0f4781076864e60db0dabd52c8e0cd8955b7e2a9"><code>0f47810</code></a> red_knot_python_semantic: improve diagnostics for unsupported boolean convers...</li> <li><a href="https://github.com/astral-sh/ruff/commit/eb1d2518c131e31ab1a1faee9061f79ed23b3eff"><code>eb1d251</code></a> red_knot_python_semantic: add &quot;return type span&quot; helper method</li> <li><a href="https://github.com/astral-sh/ruff/commit/a45a0a92bd1a9cea2a48e6c00c44c206e56da6b5"><code>a45a0a9</code></a> red_knot_python_semantic: move parameter span helper method</li> <li><a href="https://github.com/astral-sh/ruff/commit/43bd0437559a5c267b1ac8b44dfc436d7fcff3bb"><code>43bd043</code></a> ruff_db: add a <code>From</code> impl for <code>FileRange</code> to <code>Span</code></li> <li><a href="https://github.com/astral-sh/ruff/commit/9a54ee3a1cb030027dc83e6257599ed06e6f28ba"><code>9a54ee3</code></a> red_knot_python_semantic: add snapshot tests for unsupported boolean conversions</li> <li><a href="https://github.com/astral-sh/ruff/commit/25c3be51d24e4436654baabe8f4ae79dfc31fa02"><code>25c3be5</code></a> [red-knot] simplify != narrowing (<a href="https://redirect.github.com/astral-sh/ruff/issues/17610">#17610</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/e71f3ed2c589976aaae5de69639351ab132790db"><code>e71f3ed</code></a> [red-knot] Update <code>==</code> and <code>!=</code> narrowing (<a href="https://redirect.github.com/astral-sh/ruff/issues/17567">#17567</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ruff/compare/0.5.7...0.11.7">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ruff&package-manager=pip&previous-version=0.5.7&new-version=0.11.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
2 parents 9ce5e45 + fcab295 commit 65236b9

23 files changed

+173
-194
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ruff: noqa
1+
# ruff: noqa: ANN001
22
# Configuration file for the Sphinx documentation builder.
33
#
44
# For the full list of built-in configuration values, see the documentation:

examples/payments/payments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from algokit_utils import AlgorandClient
2+
13
from algokit_subscriber.subscriber import AlgorandSubscriber
24
from algokit_subscriber.types.subscription import SubscribedTransaction
3-
from algokit_utils import AlgorandClient
45

56
algorand = AlgorandClient.mainnet()
67

examples/usdc/usdc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from algokit_utils import AlgorandClient
2+
13
from algokit_subscriber.subscriber import AlgorandSubscriber
24
from algokit_subscriber.types.subscription import SubscribedTransaction
3-
from algokit_utils import AlgorandClient
45

56
algorand = AlgorandClient.mainnet()
67

poetry.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ py-algorand-sdk = "^2.7.0"
1313
algokit-utils = "^3.0.0"
1414
python-semantic-release = "^9.8.8"
1515
mypy = "^1.10.1"
16-
ruff = "^0.5.0"
16+
ruff = "^0.11.7"
1717
pytest = "^8.3.5"
1818
pre-commit = "^4.2.0"
1919
black = "^24.8.0"
@@ -87,8 +87,6 @@ lint.select = [
8787
"RUF", # Ruff-specific rules
8888
]
8989
lint.ignore = [
90-
"ANN101", # no type for self
91-
"ANN102", # no type for cls
9290
"RET505", # allow else after return
9391
"SIM108", # allow if-else in place of ternary
9492
"E111", # indentation is not a multiple of four

src/algokit_subscriber/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
__all__ = [
1616
"AlgorandSubscriber",
1717
"AlgorandSubscriberConfig",
18-
"TransactionSubscriptionParams",
19-
"TransactionSubscriptionResult",
20-
"NamedTransactionFilter",
21-
"TransactionFilter",
22-
"EventListener",
2318
"Arc28EventGroup",
24-
"SubscribedTransaction",
25-
"get_subscribed_transactions",
2619
"BalanceChange",
2720
"BalanceChangeRole",
21+
"EventListener",
22+
"NamedTransactionFilter",
23+
"SubscribedTransaction",
24+
"TransactionFilter",
25+
"TransactionSubscriptionParams",
26+
"TransactionSubscriptionResult",
27+
"get_subscribed_transactions",
2828
]

src/algokit_subscriber/block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def block_response_to_block_data(response: bytes) -> BlockData:
1212
return cast(
13-
BlockData,
13+
"BlockData",
1414
msgpack.unpackb(
1515
response, strict_map_key=False, unicode_errors="surrogateescape"
1616
),
@@ -41,7 +41,7 @@ def get_blocks_bulk(context: dict[str, int], client: AlgodClient) -> list[BlockD
4141
params={"format": "msgpack"},
4242
response_format="msgpack",
4343
)
44-
decoded = block_response_to_block_data(cast(bytes, response))
44+
decoded = block_response_to_block_data(cast("bytes", response))
4545
blocks.append(decoded)
4646

4747
elapsed_time = time.time() - start_time

src/algokit_subscriber/indexer_lookup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ def extract_items(response: TransactionSearchResults) -> list[TransactionResult]
127127
nonlocal current_round
128128
if "message" in response:
129129
raise Exception({"status": 404, **response})
130-
if response["current-round"] > current_round:
131-
current_round = response["current-round"]
130+
current_round = max(current_round, response["current-round"])
132131
return response["transactions"]
133132

134133
def build_request(next_token: str | None = None) -> dict[str, Any]:

src/algokit_subscriber/subscriber.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def __init__(
4747
)
4848

4949
def default_error_handler(
50-
self, error: Any, _str: str | None = None # noqa: ANN401
50+
self,
51+
error: Any, # noqa: ANN401
52+
_str: str | None = None,
5153
) -> None:
5254
raise error
5355

@@ -56,15 +58,15 @@ def poll_once(self) -> TransactionSubscriptionResult:
5658
Execute a single subscription poll.
5759
"""
5860
watermark = self.config["watermark_persistence"]["get"]() or 0
59-
current_round = cast(dict, self.algod.status())["last-round"]
61+
current_round = cast("dict", self.algod.status())["last-round"]
6062

6163
self.event_emitter.emit(
6264
"before:poll", {"watermark": watermark, "current_round": current_round}
6365
)
6466

6567
poll_result = get_subscribed_transactions(
6668
subscription=cast(
67-
TransactionSubscriptionParams,
69+
"TransactionSubscriptionParams",
6870
{"watermark": watermark, "current_round": current_round, **self.config},
6971
),
7072
algod=self.algod,

src/algokit_subscriber/subscription.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,13 @@ def filter_transaction(t: TransactionResult) -> bool: # noqa: C901, PLR0912
275275
if subscription.get("receiver"):
276276
if isinstance(subscription["receiver"], str):
277277
result = result and bool(
278-
axfer
279-
and axfer.get("receiver") == subscription["receiver"]
280-
or pay
281-
and pay.get("receiver") == subscription["receiver"]
278+
(axfer and axfer.get("receiver") == subscription["receiver"])
279+
or (pay and pay.get("receiver") == subscription["receiver"])
282280
)
283281
else:
284282
result = result and bool(
285-
axfer
286-
and axfer.get("receiver") in subscription["receiver"]
287-
or pay
288-
and pay.get("receiver") in subscription["receiver"]
283+
(axfer and axfer.get("receiver") in subscription["receiver"])
284+
or (pay and pay.get("receiver") in subscription["receiver"])
289285
)
290286

291287
if subscription.get("type"):
@@ -312,42 +308,40 @@ def filter_transaction(t: TransactionResult) -> bool: # noqa: C901, PLR0912
312308
if isinstance(subscription["app_id"], int):
313309
result = result and bool(
314310
t.get("created-application-index") == int(subscription["app_id"])
315-
or appl
316-
and appl.get("application-id") == int(subscription["app_id"])
311+
or (
312+
appl
313+
and appl.get("application-id") == int(subscription["app_id"])
314+
)
317315
)
318316
else:
319317
result = result and bool(
320318
(
321319
(t.get("created-application-index") or 0)
322320
in map(int, subscription["app_id"])
323321
)
324-
or appl
325-
and appl.get("application-id", 0)
326-
in map(int, subscription["app_id"])
322+
or (
323+
appl
324+
and appl.get("application-id", 0)
325+
in map(int, subscription["app_id"])
326+
)
327327
)
328328

329329
if subscription.get("asset_id"):
330330
if isinstance(subscription["asset_id"], int | float):
331331
asset_id = int(subscription["asset_id"])
332332
result = result and bool(
333333
t.get("created-asset-index") == asset_id
334-
or acfg
335-
and acfg.get("asset-id") == asset_id
336-
or acfg
337-
and acfg.get("asset-id") == asset_id
338-
or axfer
339-
and axfer.get("asset-id") == asset_id
334+
or (acfg and acfg.get("asset-id") == asset_id)
335+
or (acfg and acfg.get("asset-id") == asset_id)
336+
or (axfer and axfer.get("asset-id") == asset_id)
340337
)
341338
else:
342339
asset_ids = set(map(int, subscription["asset_id"]))
343340
result = result and bool(
344341
t.get("created-asset-index") in asset_ids
345-
or axfer
346-
and axfer.get("asset-id") in asset_ids
347-
or acfg
348-
and acfg.get("asset-id") in asset_ids
349-
or afrz
350-
and afrz.get("asset-id") in asset_ids
342+
or (axfer and axfer.get("asset-id") in asset_ids)
343+
or (acfg and acfg.get("asset-id") in asset_ids)
344+
or (afrz and afrz.get("asset-id") in asset_ids)
351345
)
352346

353347
if subscription.get("min_amount"):
@@ -485,7 +479,7 @@ def check_single_change(actual_change: dict, change_filter: dict) -> bool:
485479

486480
return any(
487481
any(
488-
check_single_change(cast(dict, actual_change), change_filter)
482+
check_single_change(cast("dict", actual_change), change_filter)
489483
for actual_change in transaction_balance_changes
490484
)
491485
for change_filter in filtered_balance_changes
@@ -511,7 +505,7 @@ def get_subscribed_transactions( # noqa: C901, PLR0912, PLR0915
511505
max_rounds_to_sync = subscription.get("max_rounds_to_sync") or 500
512506
sync_behaviour = subscription["sync_behaviour"]
513507
current_round = subscription.get("current_round") or cast(
514-
dict[str, Any], algod.status()
508+
"dict[str, Any]", algod.status()
515509
).get("last-round", 0)
516510
block_metadata: list[BlockMetadata] | None = None
517511

@@ -637,8 +631,7 @@ def get_subscribed_transactions( # noqa: C901, PLR0912, PLR0915
637631
)
638632

639633
logger.debug(
640-
f"Retrieved {len(catchup_transactions)} transactions from round {start_round} to round "
641-
f"{algod_sync_from_round_number - 1} via indexer in {(time.time() - start):.3f}s"
634+
f"Retrieved {len(catchup_transactions)} transactions from round {start_round} to round {algod_sync_from_round_number - 1} via indexer in {(time.time() - start):.3f}s"
642635
)
643636
else:
644637
raise NotImplementedError("Not implemented")
@@ -670,8 +663,7 @@ def get_subscribed_transactions( # noqa: C901, PLR0912, PLR0915
670663
block_metadata = [block_data_to_block_metadata(b) for b in blocks]
671664

672665
logger.debug(
673-
f"Retrieved {len(block_transactions)} transactions from algod via round(s) {algod_sync_from_round_number}-{end_round} "
674-
f"in {(time.time() - start):.3f}s"
666+
f"Retrieved {len(block_transactions)} transactions from algod via round(s) {algod_sync_from_round_number}-{end_round} in {(time.time() - start):.3f}s"
675667
)
676668
else:
677669
logger.debug(
@@ -955,7 +947,7 @@ def get_indexer_inner_transactions(
955947
parent_offset = offset()
956948
result.append(
957949
cast(
958-
SubscribedTransaction,
950+
"SubscribedTransaction",
959951
{
960952
**t,
961953
"parent_transaction_id": root["id"],

src/algokit_subscriber/transform.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ def get_parent_offset() -> int:
154154
)
155155

156156
if (
157-
block_transaction.get("dt") is None
158-
or block_transaction["dt"].get("itx") is None # type: ignore[union-attr]
157+
block_transaction.get("dt") is None or block_transaction["dt"].get("itx") is None # type: ignore[union-attr]
159158
):
160159
continue
161160

@@ -447,7 +446,7 @@ def get_child_offset() -> int:
447446
return child_offset + 1
448447

449448
if "get_child_offset" in t:
450-
get_child_offset = cast(TransactionInBlockWithChildOffset, t)[
449+
get_child_offset = cast("TransactionInBlockWithChildOffset", t)[
451450
"get_child_offset"
452451
]
453452

@@ -496,7 +495,7 @@ def get_child_offset() -> int:
496495
"closing-amount": close_amount,
497496
"created-application-index": created_app_id,
498497
"auth-addr": (
499-
encode_address(cast(bytes, block_transaction.get("sgnr")))
498+
encode_address(cast("bytes", block_transaction.get("sgnr")))
500499
if block_transaction.get("sgnr")
501500
else None
502501
),
@@ -671,7 +670,7 @@ def get_child_offset() -> int:
671670
for ibt in block_transaction["dt"].get("itx", []) # type: ignore[union-attr]
672671
]
673672

674-
return cast(SubscribedTransaction, convert_bytes_to_base64(result))
673+
return cast("SubscribedTransaction", convert_bytes_to_base64(result))
675674

676675
except Exception as e:
677676
logger.error(

0 commit comments

Comments
 (0)