fix: style - after update of black to v26.3.1
What changed, and why it matters
This commit is purely a code-style cleanup triggered by an update to the Python formatter 'black'. It removes unnecessary parentheses around tuple unpacking and adjusts some string-literal formatting. There is no functional change and no security relevance.
No action required; this is a benign style-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows only formatting changes produced by black v26.3.1: tuple unpacking patterns like (a, b) = ... are rewritten as a, b = ..., and a few multiline string literals are collapsed. No logic, constants, imports, or control flow are altered. The commit message explicitly labels it as a style fix and includes ‘[no changelog]’.
Changed components
Python source formatting across CI scripts, core firmware Python code, legacy tooling, python/trezorlib, and test suitesInspect captured patch +38 / −45
diff --git a/ci/make_crowdin_comment.py b/ci/make_crowdin_comment.py
index 6b0dcaf8..c5c9925d 100644
--- a/ci/make_crowdin_comment.py
+++ b/ci/make_crowdin_comment.py
@@ -1,7 +1,7 @@
import json
import sys
-(RUN_ID, LANGS_JSON) = sys.argv[1:]
+RUN_ID, LANGS_JSON = sys.argv[1:]
MAIN = json.loads(LANGS_JSON)
REPORT_URL = f"https://data.trezor.io/dev/firmware/ui_report/{RUN_ID}"
diff --git a/ci/make_pull_comment.py b/ci/make_pull_comment.py
index 28f28217..331f011a 100644
--- a/ci/make_pull_comment.py
+++ b/ci/make_pull_comment.py
@@ -1,7 +1,7 @@
import json
import sys
-(RUN_ID, LANGS_JSON) = sys.argv[1:]
+RUN_ID, LANGS_JSON = sys.argv[1:]
MAIN, *EXTRA = json.loads(LANGS_JSON)
REPORT_URL = f"https://data.trezor.io/dev/firmware/ui_report/{RUN_ID}"
diff --git a/ci/make_summary_htmls.py b/ci/make_summary_htmls.py
index 38f468b7..7d878f08 100644
--- a/ci/make_summary_htmls.py
+++ b/ci/make_summary_htmls.py
@@ -1,7 +1,7 @@
import json
import sys
-(SUFFIX, LANGS_JSON, TARGET) = sys.argv[1:]
+SUFFIX, LANGS_JSON, TARGET = sys.argv[1:]
LANGS = json.loads(LANGS_JSON)
for lang in LANGS:
diff --git a/ci/prepare_ui_artifacts.py b/ci/prepare_ui_artifacts.py
index cd97555b..c31d6889 100644
--- a/ci/prepare_ui_artifacts.py
+++ b/ci/prepare_ui_artifacts.py
@@ -8,7 +8,6 @@ sys.path.insert(0, str(ROOT))
from tests.ui_tests.common import TestResult, _hash_files # isort:skip
from tests.ui_tests.common import get_current_fixtures # isort:skip
-
FIXTURES = get_current_fixtures()
for result in TestResult.recent_results():
diff --git a/common/tools/marketcap.py b/common/tools/marketcap.py
index 1ed16e32..d2e98df6 100644
--- a/common/tools/marketcap.py
+++ b/common/tools/marketcap.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Fetch market capitalization data."""
+
import json
import os
import time
diff --git a/common/tools/maxfee.py b/common/tools/maxfee.py
index 4cfbe73c..1bcf4685 100644
--- a/common/tools/maxfee.py
+++ b/common/tools/maxfee.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Updates maxfee_kb in given JSON coin definitions."""
+
import glob
import json
import logging
diff --git a/core/src/trezor/crypto/slip39.py b/core/src/trezor/crypto/slip39.py
index b343ce0f..399a8f99 100644
--- a/core/src/trezor/crypto/slip39.py
+++ b/core/src/trezor/crypto/slip39.py
@@ -170,7 +170,7 @@ def decrypt(
r = encrypted_master_secret[len(encrypted_master_secret) // 2 :]
salt = _get_salt(identifier, extendable)
for i in reversed(range(_ROUND_COUNT)):
- (l, r) = (
+ l, r = (
r,
_xor(l, _round_function(i, passphrase, iteration_exponent, salt, r)),
)
diff --git a/core/src/trezor/ui/layouts/bolt/__init__.py b/core/src/trezor/ui/layouts/bolt/__init__.py
index 84f7aa14..de3e6a5b 100644
--- a/core/src/trezor/ui/layouts/bolt/__init__.py
+++ b/core/src/trezor/ui/layouts/bolt/__init__.py
@@ -1384,8 +1384,8 @@ if not utils.BITCOIN_ONLY:
) -> None:
from ..properties import with_colon
- (amount_label, amount, _is_data) = amount_item or ("", "", None)
- (fee_label, fee, _is_data) = fee_item
+ amount_label, amount, _is_data = amount_item or ("", "", None)
+ fee_label, fee, _is_data = fee_item
confirm_layout = trezorui_api.confirm_value(
title=title,
diff --git a/core/src/trezor/ui/layouts/eckhart/__init__.py b/core/src/trezor/ui/layouts/eckhart/__init__.py
index 2c74ff2c..eb4aa57b 100644
--- a/core/src/trezor/ui/layouts/eckhart/__init__.py
+++ b/core/src/trezor/ui/layouts/eckhart/__init__.py
@@ -466,7 +466,7 @@ async def confirm_payment_request(
from ..slip24 import is_swap
- (title, summary_title) = (
+ title, summary_title = (
(TR.words__swap, TR.words__swap)
if is_swap(trades)
else (TR.words__confirm, TR.words__title_summary)
diff --git a/core/src/trezor/wire/thp/interface_context.py b/core/src/trezor/wire/thp/interface_context.py
index 07770570..4ce076ab 100644
--- a/core/src/trezor/wire/thp/interface_context.py
+++ b/core/src/trezor/wire/thp/interface_context.py
@@ -72,7 +72,7 @@ class ThpContext:
else:
race_task = race(*children, _timeout_after(timeout_ms))
- (iface_ctx, packet_len) = await race_task # will raise on timeout
+ iface_ctx, packet_len = await race_task # will raise on timeout
assert packet_len == iface_ctx._iface.RX_PACKET_LEN
# read and handle the packet using its `InterfaceContext`
diff --git a/core/tests/test_trezor.crypto.curve.secp256k1.py b/core/tests/test_trezor.crypto.curve.secp256k1.py
index 518502b8..2075d8a9 100644
--- a/core/tests/test_trezor.crypto.curve.secp256k1.py
+++ b/core/tests/test_trezor.crypto.curve.secp256k1.py
@@ -258,7 +258,7 @@ class TestCryptoSecp256k1(unittest.TestCase):
pk2 = secp256k1.publickey(sk2, True)
self.assertEqual(secp256k1.multiply(sk1, pk2), secp256k1.multiply(sk2, pk1))
- (sk, pk) = self.vectors[0]
+ sk, pk = self.vectors[0]
sk = hex(sk)[2:]
if len(sk) < 64:
sk = "0" * (64 - len(sk)) + sk
diff --git a/core/tools/analyze-memory-dump.py b/core/tools/analyze-memory-dump.py
index d712e424..2c8383b4 100755
--- a/core/tools/analyze-memory-dump.py
+++ b/core/tools/analyze-memory-dump.py
@@ -10,8 +10,7 @@ from typing import Any, Iterator, Optional
from typing_extensions import TypeGuard
if len(sys.argv) < 2:
- print(
- """\
+ print("""\
USAGE: ./analyze-memory-dump.py somefile.json [memorymap.html]
Where "somefile.json" was produced by using `trezor.utils.mem_dump("somefile.json")`
@@ -32,13 +31,12 @@ actually care about.
Modules are nothing but a link to a globals dict. The dict must be examined separately.
Generators and closures are painful :(
-"""
- )
+""")
with open(sys.argv[1]) as f:
MEMMAP = iter(json.load(f))
- (min_ptr, max_ptr, bytes_per_block) = next(MEMMAP)
+ min_ptr, max_ptr, bytes_per_block = next(MEMMAP)
# filter out notices and comments
@@ -267,8 +265,7 @@ import dominate.tags as t
doc = dominate.document(title="memory map")
with doc.head:
t.meta(charset="utf-8")
- t.style(
- """\
+ t.style("""\
span, a {
font-family: monospace;
color: black;
@@ -297,8 +294,7 @@ dl { border-left: 1px solid grey; padding-left: 0.4rem; }
dt { font-weight: bold }
div.
-"""
- )
+""")
ctr = 0
newline = True
diff --git a/legacy/debug_signing/fill_t1_fw_signatures.py b/legacy/debug_signing/fill_t1_fw_signatures.py
index e3629d72..8e06170e 100755
--- a/legacy/debug_signing/fill_t1_fw_signatures.py
+++ b/legacy/debug_signing/fill_t1_fw_signatures.py
@@ -50,7 +50,7 @@ class Signatures:
for i in range(len(self.signature_pairs)):
sigindex_ofs = self.sigindex_offsets[i]
sig_ofs = self.sig_offsets[i]
- (sigindex, sig) = self.signature_pairs[i]
+ sigindex, sig = self.signature_pairs[i]
print(f"Patching sigindex {sigindex} at offset {sigindex_ofs}")
assert 1 <= sigindex <= 5
diff --git a/legacy/gen/bitmaps/generate.py b/legacy/gen/bitmaps/generate.py
index 34a1e545..401b41dc 100755
--- a/legacy/gen/bitmaps/generate.py
+++ b/legacy/gen/bitmaps/generate.py
@@ -43,8 +43,7 @@ with open("../bitmaps.c", "wt") as f:
f.close()
with open("../bitmaps.h", "wt") as f:
- f.write(
- """#ifndef __BITMAPS_H__
+ f.write("""#ifndef __BITMAPS_H__
#define __BITMAPS_H__
#include <stdint.h>
@@ -54,8 +53,7 @@ typedef struct {
const uint8_t *data;
} BITMAP;
-"""
- )
+""")
for i in range(cnt):
f.write(hdrs[i])
diff --git a/python/src/trezorlib/_ed25519.py b/python/src/trezorlib/_ed25519.py
index 6f5a74bb..135ac42e 100644
--- a/python/src/trezorlib/_ed25519.py
+++ b/python/src/trezorlib/_ed25519.py
@@ -103,8 +103,8 @@ ident = Point((0, 1, 1, 0))
def edwards_add(P: Point, Q: Point) -> Point:
# This is formula sequence 'addition-add-2008-hwcd-3' from
# http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- (x1, y1, z1, t1) = P
- (x2, y2, z2, t2) = Q
+ x1, y1, z1, t1 = P
+ x2, y2, z2, t2 = Q
a = (y1 - x1) * (y2 - x2) % q
b = (y1 + x1) * (y2 + x2) % q
@@ -125,7 +125,7 @@ def edwards_add(P: Point, Q: Point) -> Point:
def edwards_double(P: Point) -> Point:
# This is formula sequence 'dbl-2008-hwcd' from
# http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- (x1, y1, z1, _) = P
+ x1, y1, z1, _ = P
a = x1 * x1 % q
b = y1 * y1 % q
@@ -187,7 +187,7 @@ def encodeint(y: int) -> bytes:
def encodepoint(P: Point) -> bytes:
- (x, y, z, _) = P
+ x, y, z, _ = P
zi = inv(z)
x = (x * zi) % q
y = (y * zi) % q
@@ -257,7 +257,7 @@ def signature_unsafe(m: bytes, sk: bytes, pk: bytes) -> bytes:
def isoncurve(P: Point) -> bool:
- (x, y, z, t) = P
+ x, y, z, t = P
return (
z % q != 0
and x * y % q == z * t % q
@@ -287,8 +287,8 @@ def checkvalid(s: bytes, m: bytes, pk: bytes) -> None:
S = decodeint(s[b // 8 : b // 4])
h = Hint(encodepoint(R) + pk + m)
- (x1, y1, z1, _) = P = scalarmult_B(S)
- (x2, y2, z2, _) = Q = edwards_add(R, scalarmult(A, h))
+ x1, y1, z1, _ = P = scalarmult_B(S)
+ x2, y2, z2, _ = Q = edwards_add(R, scalarmult(A, h))
if (
not isoncurve(P)
diff --git a/python/src/trezorlib/thp/curve25519.py b/python/src/trezorlib/thp/curve25519.py
index 7f8bfb5b..ca1d07e1 100644
--- a/python/src/trezorlib/thp/curve25519.py
+++ b/python/src/trezorlib/thp/curve25519.py
@@ -120,13 +120,13 @@ def multiply(private_scalar: bytes, public_point: bytes) -> bytes:
for i in reversed(range(256)):
bit = (k >> i) & 1
swap = bit ^ swap
- (x_2, x_3) = conditional_swap(x_2, x_3, swap)
- (z_2, z_3) = conditional_swap(z_2, z_3, swap)
+ x_2, x_3 = conditional_swap(x_2, x_3, swap)
+ z_2, z_3 = conditional_swap(z_2, z_3, swap)
swap = bit
x_2, z_2, x_3, z_3 = ladder_operation(x_1, x_2, z_2, x_3, z_3)
- (x_2, x_3) = conditional_swap(x_2, x_3, swap)
- (z_2, z_3) = conditional_swap(z_2, z_3, swap)
+ x_2, x_3 = conditional_swap(x_2, x_3, swap)
+ z_2, z_3 = conditional_swap(z_2, z_3, swap)
x = pow(z_2, p - 2, p) * x_2 % p
return encode_coordinate(x)
diff --git a/tests/click_tests/record_layout.py b/tests/click_tests/record_layout.py
index e4b76d06..98c53513 100644
--- a/tests/click_tests/record_layout.py
+++ b/tests/click_tests/record_layout.py
@@ -268,14 +268,12 @@ def call_to_strs(call):
if __name__ == "__main__":
- echo(
- """\
+ echo("""\
Quick&Dirty Test Case Recorder.
Use as you would use trezorctl, input clicking commands via host keyboard
for best results.
-"""
- )
+""")
try:
main()
finally:
diff --git a/tests/device_tests/bitcoin/test_bcash.py b/tests/device_tests/bitcoin/test_bcash.py
index a549e943..b9c4440a 100644
--- a/tests/device_tests/bitcoin/test_bcash.py
+++ b/tests/device_tests/bitcoin/test_bcash.py
@@ -345,7 +345,7 @@ def test_send_bch_multisig_wrongchange(session: Session):
request_finished(),
]
)
- (signatures1, serialized_tx) = btc.sign_tx(
+ signatures1, serialized_tx = btc.sign_tx(
session, "Bcash", [inp1], [out1], prev_txes=TX_API
)
assert (
@@ -414,7 +414,7 @@ def test_send_bch_multisig_change(session: Session):
request_finished(),
]
)
- (signatures1, serialized_tx) = btc.sign_tx(
+ signatures1, serialized_tx = btc.sign_tx(
session, "Bcash", [inp1], [out1, out2], prev_txes=TX_API
)
@@ -453,7 +453,7 @@ def test_send_bch_multisig_change(session: Session):
request_finished(),
]
)
- (signatures1, serialized_tx) = btc.sign_tx(
+ signatures1, serialized_tx = btc.sign_tx(
session, "Bcash", [inp1], [out1, out2], prev_txes=TX_API
)
diff --git a/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py b/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py
index 51216397..3e787780 100644
--- a/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py
+++ b/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py
@@ -71,7 +71,7 @@ def test_pin_passphrase(test_ctx: TrezorTestContext):
fakes = 0
for _ in range(int(12 * 2)):
assert isinstance(ret, messages.WordRequest)
- (word, pos) = debug.read_recovery_word()
+ word, pos = debug.read_recovery_word()
if pos != 0:
ret = session.call_raw(messages.WordAck(word=mnemonic[pos - 1]))
@@ -140,7 +140,7 @@ def test_nopin_nopassphrase(test_ctx: TrezorTestContext):
fakes = 0
for _ in range(int(12 * 2)):
assert isinstance(ret, messages.WordRequest)
- (word, pos) = debug.read_recovery_word()
+ word, pos = debug.read_recovery_word()
if pos != 0:
ret = session.call_raw(messages.WordAck(word=mnemonic[pos - 1]))
@@ -189,7 +189,7 @@ def test_word_fail(session: Session):
assert isinstance(ret, messages.WordRequest)
for _ in range(int(24 * 2)):
- (word, pos) = debug.read_recovery_word()
+ word, pos = debug.read_recovery_word()
if pos != 0:
ret = session.call_raw(messages.WordAck(word="kwyjibo"))
assert isinstance(ret, messages.Failure)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.