From c807ae82121a5177e627b34765f7f3799299a004 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:48 +0000 Subject: [PATCH] ruff UP006 (use `list` instead of `List` for type annotation) --- mmgen/proto/cosmos/tx/protobuf.py | 12 ++++++------ mmgen/proto/rune/tx/protobuf.py | 10 +++++----- pyproject.toml | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/mmgen/proto/cosmos/tx/protobuf.py b/mmgen/proto/cosmos/tx/protobuf.py index 7de70bc1..90c24ef2 100755 --- a/mmgen/proto/cosmos/tx/protobuf.py +++ b/mmgen/proto/cosmos/tx/protobuf.py @@ -21,7 +21,7 @@ from hashlib import sha256 from dataclasses import dataclass from pure_protobuf.annotations import Field from pure_protobuf.message import BaseMessage -from typing import Annotated, List, Optional +from typing import Annotated, Optional from enum import IntEnum class SignMode(IntEnum): @@ -52,7 +52,7 @@ class ModeInfo(BaseMessage): @dataclass class Multi(BaseMessage): bitarray: Annotated[bytes, Field(1)] - modeInfos: Annotated[List[bytes], Field(2)] + modeInfos: Annotated[list[bytes], Field(2)] single: Annotated[Optional[Single], Field(1)] = None multi: Annotated[Optional[Multi], Field(2)] = None @@ -74,14 +74,14 @@ class Coin(BaseMessage): @dataclass class Fee(BaseMessage): - amount: Annotated[Optional[List[Coin]], Field(1)] = None # = field(default_factory=list) + amount: Annotated[Optional[list[Coin]], Field(1)] = None # = field(default_factory=list) gasLimit: Annotated[Optional[int], Field(2)] = None payer: Annotated[Optional[str], Field(3)] = None granter: Annotated[Optional[str], Field(4)] = None @dataclass class AuthInfo(BaseMessage): - signerInfos: Annotated[List[SignerInfo], Field(1)] + signerInfos: Annotated[list[SignerInfo], Field(1)] fee: Annotated[Optional[Fee], Field(2)] = None tip: Annotated[Optional[int], Field(3)] = None @@ -93,7 +93,7 @@ class AuthInfo(BaseMessage): class RawTx(BaseMessage): # TxRaw (cosmjs) bodyBytes: Annotated[bytes, Field(1)] authInfoBytes: Annotated[bytes, Field(2)] - signatures: Annotated[List[bytes], Field(3)] + signatures: Annotated[list[bytes], Field(3)] # SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT @dataclass @@ -120,7 +120,7 @@ class TxMsg(BaseMessage): class Tx(BaseMessage): body: Annotated[bytes, Field(1)] authInfo: Annotated[bytes, Field(2)] - signatures: Annotated[List[bytes], Field(3)] + signatures: Annotated[list[bytes], Field(3)] @property def raw(self): diff --git a/mmgen/proto/rune/tx/protobuf.py b/mmgen/proto/rune/tx/protobuf.py index 363ce0d4..3a4fee88 100755 --- a/mmgen/proto/rune/tx/protobuf.py +++ b/mmgen/proto/rune/tx/protobuf.py @@ -17,7 +17,7 @@ proto.rune.tx.protobuf: transaction serialization for THORChain protocol from decimal import Decimal from collections import namedtuple from dataclasses import dataclass #, field -from typing import Annotated, List, Optional +from typing import Annotated, Optional from pure_protobuf.annotations import Field from pure_protobuf.message import BaseMessage @@ -107,7 +107,7 @@ class Messages: class Body(BaseMessage): fromAddress: Annotated[bytes, Field(1)] toAddress: Annotated[bytes, Field(2)] - amount: Annotated[List[Coin], Field(3)] + amount: Annotated[list[Coin], Field(3)] id: Annotated[str, Field(1)] # '/types.MsgSend' body: Annotated[Body, Field(2)] @@ -123,7 +123,7 @@ class Messages: # } @dataclass class Body(BaseMessage): - coins: Annotated[List[CoinWithAsset], Field(1)] + coins: Annotated[list[CoinWithAsset], Field(1)] memo: Annotated[str, Field(2)] signer: Annotated[bytes, Field(3)] @@ -138,7 +138,7 @@ class RuneTxMsg(TxMsg): @dataclass class RuneTxBody(BaseMessage): - messages: Annotated[List[RuneTxMsg], Field(1)] + messages: Annotated[list[RuneTxMsg], Field(1)] memo: Annotated[Optional[str], Field(2)] = None timeoutHeight: Annotated[Optional[int], Field(3)] = None extensionOptions: Annotated[Optional[bytes], Field(4)] = None @@ -148,7 +148,7 @@ class RuneTxBody(BaseMessage): class RuneTx(Tx): body: Annotated[RuneTxBody, Field(1)] authInfo: Annotated[AuthInfo, Field(2)] - signatures: Annotated[List[bytes], Field(3)] + signatures: Annotated[list[bytes], Field(3)] def amt_to_base_unit(amt, *, decimals): return int(Decimal(amt) * (Decimal(10) ** decimals)) diff --git a/pyproject.toml b/pyproject.toml index 2f275174..f7feefa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ ignore = [ "SIM102", # Use a single `if` statement instead of nested `if` statements "SIM114", # Combine `if` branches using logical `or` operator "SIM905", # Consider using a list literal instead of `str.split` - "UP006", # Use `list` instead of `List` for type annotation "UP022", # Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` "UP030", # Use implicit references for positional format fields "UP031", # Use format specifiers instead of percent format