From 3b4c40722b252243de47e2a976cb052d0faf3c8b Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Mon, 12 Feb 2024 05:34:21 +0400 Subject: [PATCH] lint --- src/spl/token/async_client.py | 6 +++--- src/spl/token/client.py | 6 +++--- src/spl/token/core.py | 10 +++++----- src/spl/token/instructions.py | 2 +- tests/conftest.py | 6 +++--- tests/integration/test_async_http_client.py | 11 ++++++----- tests/integration/test_http_client.py | 11 ++++++----- tests/integration/test_memo.py | 7 ++++--- tests/integration/test_websockets.py | 9 +++++---- tests/unit/test_async_client.py | 5 +++-- tests/unit/test_client.py | 5 +++-- tests/unit/test_confirmed_block.py | 3 ++- tests/unit/test_security_txt.py | 1 + tests/unit/test_transaction.py | 3 ++- tests/unit/test_vote_program.py | 5 +++-- tests/utils.py | 3 ++- 16 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/spl/token/async_client.py b/src/spl/token/async_client.py index 0a260919..640d67a9 100644 --- a/src/spl/token/async_client.py +++ b/src/spl/token/async_client.py @@ -4,9 +4,6 @@ from typing import List, Optional, Union, cast -from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Commitment -from solana.rpc.types import TxOpts from solders.hash import Hash as Blockhash from solders.keypair import Keypair from solders.pubkey import Pubkey @@ -20,6 +17,9 @@ ) import spl.token.instructions as spl_token +from solana.rpc.async_api import AsyncClient +from solana.rpc.commitment import Commitment +from solana.rpc.types import TxOpts from spl.token._layouts import ACCOUNT_LAYOUT, MINT_LAYOUT, MULTISIG_LAYOUT from spl.token.core import AccountInfo, MintInfo, _TokenCore diff --git a/src/spl/token/client.py b/src/spl/token/client.py index cba7aa82..e44f5309 100644 --- a/src/spl/token/client.py +++ b/src/spl/token/client.py @@ -4,9 +4,6 @@ from typing import List, Optional, Union, cast -from solana.rpc.api import Client -from solana.rpc.commitment import Commitment -from solana.rpc.types import TxOpts from solders.hash import Hash as Blockhash from solders.keypair import Keypair from solders.pubkey import Pubkey @@ -20,6 +17,9 @@ ) import spl.token.instructions as spl_token +from solana.rpc.api import Client +from solana.rpc.commitment import Commitment +from solana.rpc.types import TxOpts from spl.token._layouts import ACCOUNT_LAYOUT, MINT_LAYOUT, MULTISIG_LAYOUT from spl.token.core import AccountInfo, MintInfo, _TokenCore diff --git a/src/spl/token/core.py b/src/spl/token/core.py index 581579c6..1ff1b030 100644 --- a/src/spl/token/core.py +++ b/src/spl/token/core.py @@ -5,16 +5,16 @@ from typing import TYPE_CHECKING, List, NamedTuple, Optional, Tuple, Type, Union import solders.system_program as sp -from solana.rpc.api import Client -from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Commitment -from solana.rpc.types import TokenAccountOpts, TxOpts -from solana.transaction import Transaction from solders.keypair import Keypair from solders.pubkey import Pubkey from solders.rpc.responses import GetAccountInfoResp import spl.token.instructions as spl_token +from solana.rpc.api import Client +from solana.rpc.async_api import AsyncClient +from solana.rpc.commitment import Commitment +from solana.rpc.types import TokenAccountOpts, TxOpts +from solana.transaction import Transaction from spl.token._layouts import ACCOUNT_LAYOUT, MINT_LAYOUT, MULTISIG_LAYOUT # type: ignore from spl.token.constants import WRAPPED_SOL_MINT diff --git a/src/spl/token/instructions.py b/src/spl/token/instructions.py index b3d9688f..705d5ece 100644 --- a/src/spl/token/instructions.py +++ b/src/spl/token/instructions.py @@ -3,12 +3,12 @@ from enum import IntEnum from typing import Any, List, NamedTuple, Optional, Union -from solana.utils.validate import validate_instruction_keys, validate_instruction_type from solders.instruction import AccountMeta, Instruction from solders.pubkey import Pubkey from solders.system_program import ID as SYS_PROGRAM_ID from solders.sysvar import RENT +from solana.utils.validate import validate_instruction_keys, validate_instruction_type from spl.token._layouts import INSTRUCTIONS_LAYOUT, InstructionType from spl.token.constants import ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID diff --git a/tests/conftest.py b/tests/conftest.py index ae1ef8a4..7f665ef5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,13 +4,13 @@ from typing import NamedTuple import pytest -from solana.rpc.api import Client -from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Processed from solders.hash import Hash as Blockhash from solders.keypair import Keypair from solders.pubkey import Pubkey +from solana.rpc.api import Client +from solana.rpc.async_api import AsyncClient +from solana.rpc.commitment import Processed from tests.utils import AIRDROP_AMOUNT, assert_valid_response diff --git a/tests/integration/test_async_http_client.py b/tests/integration/test_async_http_client.py index 12004acf..2947278c 100644 --- a/tests/integration/test_async_http_client.py +++ b/tests/integration/test_async_http_client.py @@ -3,11 +3,6 @@ import pytest import solders.system_program as sp -from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Confirmed, Finalized, Processed -from solana.rpc.core import RPCException, TransactionExpiredBlockheightExceededError -from solana.rpc.types import DataSliceOpts, TxOpts -from solana.transaction import Transaction from solders.keypair import Keypair from solders.message import MessageV0 from solders.pubkey import Pubkey @@ -17,6 +12,12 @@ from solders.transaction import VersionedTransaction from spl.token.constants import WRAPPED_SOL_MINT +from solana.rpc.async_api import AsyncClient +from solana.rpc.commitment import Confirmed, Finalized, Processed +from solana.rpc.core import RPCException, TransactionExpiredBlockheightExceededError +from solana.rpc.types import DataSliceOpts, TxOpts +from solana.transaction import Transaction + from ..utils import AIRDROP_AMOUNT, assert_valid_response diff --git a/tests/integration/test_http_client.py b/tests/integration/test_http_client.py index f4158449..ca23607e 100644 --- a/tests/integration/test_http_client.py +++ b/tests/integration/test_http_client.py @@ -3,11 +3,6 @@ import pytest import solders.system_program as sp -from solana.rpc.api import Client -from solana.rpc.commitment import Confirmed, Finalized, Processed -from solana.rpc.core import RPCException, TransactionExpiredBlockheightExceededError -from solana.rpc.types import DataSliceOpts, TxOpts -from solana.transaction import Transaction from solders.keypair import Keypair from solders.message import MessageV0 from solders.pubkey import Pubkey @@ -17,6 +12,12 @@ from solders.transaction import VersionedTransaction from spl.token.constants import WRAPPED_SOL_MINT +from solana.rpc.api import Client +from solana.rpc.commitment import Confirmed, Finalized, Processed +from solana.rpc.core import RPCException, TransactionExpiredBlockheightExceededError +from solana.rpc.types import DataSliceOpts, TxOpts +from solana.transaction import Transaction + from ..utils import AIRDROP_AMOUNT, assert_valid_response diff --git a/tests/integration/test_memo.py b/tests/integration/test_memo.py index dfcac459..1c7b3446 100644 --- a/tests/integration/test_memo.py +++ b/tests/integration/test_memo.py @@ -1,13 +1,14 @@ """Tests for the Memo program.""" import pytest -from solana.rpc.api import Client -from solana.rpc.commitment import Finalized -from solana.transaction import Transaction from solders.keypair import Keypair from solders.transaction_status import ParsedInstruction from spl.memo.constants import MEMO_PROGRAM_ID from spl.memo.instructions import MemoParams, create_memo +from solana.rpc.api import Client +from solana.rpc.commitment import Finalized +from solana.transaction import Transaction + from ..utils import AIRDROP_AMOUNT, assert_valid_response diff --git a/tests/integration/test_websockets.py b/tests/integration/test_websockets.py index b8097718..9bd49789 100644 --- a/tests/integration/test_websockets.py +++ b/tests/integration/test_websockets.py @@ -4,10 +4,6 @@ import asyncstdlib import pytest -from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Finalized -from solana.rpc.websocket_api import SolanaWsClientProtocol, connect -from solana.transaction import Transaction from solders import system_program as sp from solders.keypair import Keypair from solders.pubkey import Pubkey @@ -27,6 +23,11 @@ from solders.system_program import ID as SYS_PROGRAM_ID from websockets.legacy.client import WebSocketClientProtocol +from solana.rpc.async_api import AsyncClient +from solana.rpc.commitment import Finalized +from solana.rpc.websocket_api import SolanaWsClientProtocol, connect +from solana.transaction import Transaction + from ..utils import AIRDROP_AMOUNT diff --git a/tests/unit/test_async_client.py b/tests/unit/test_async_client.py index 88c3b9d2..d413e302 100644 --- a/tests/unit/test_async_client.py +++ b/tests/unit/test_async_client.py @@ -3,14 +3,15 @@ import pytest from httpx import ReadTimeout -from solana.exceptions import SolanaRpcException -from solana.rpc.commitment import Finalized from solders.commitment_config import CommitmentLevel from solders.pubkey import Pubkey from solders.rpc.config import RpcSignaturesForAddressConfig from solders.rpc.requests import GetSignaturesForAddress from solders.signature import Signature +from solana.exceptions import SolanaRpcException +from solana.rpc.commitment import Finalized + async def test_async_client_http_exception(unit_test_http_client_async): """Test AsyncClient raises native Solana-py exceptions.""" diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 99e7467d..07e0b0ea 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -3,14 +3,15 @@ import pytest from httpx import ReadTimeout -from solana.exceptions import SolanaRpcException -from solana.rpc.commitment import Finalized from solders.commitment_config import CommitmentLevel from solders.pubkey import Pubkey from solders.rpc.config import RpcSignaturesForAddressConfig from solders.rpc.requests import GetSignaturesForAddress from solders.signature import Signature +from solana.exceptions import SolanaRpcException +from solana.rpc.commitment import Finalized + def test_client_http_exception(unit_test_http_client): """Test AsyncClient raises native Solana-py exceptions.""" diff --git a/tests/unit/test_confirmed_block.py b/tests/unit/test_confirmed_block.py index bfada322..f0e49de8 100644 --- a/tests/unit/test_confirmed_block.py +++ b/tests/unit/test_confirmed_block.py @@ -1,10 +1,11 @@ """Test get confirmed block.""" -import solana.transaction as txlib from solders.keypair import Keypair from solders.signature import Signature from solders.system_program import TransferParams, transfer +import solana.transaction as txlib + def test_verify_confirmed_block(stubbed_blockhash): """Test verifying signature in a confirmed block.""" diff --git a/tests/unit/test_security_txt.py b/tests/unit/test_security_txt.py index c92f6390..a9ce63b6 100644 --- a/tests/unit/test_security_txt.py +++ b/tests/unit/test_security_txt.py @@ -1,6 +1,7 @@ """Test security txt.""" import pytest + from solana.utils.security_txt import NoSecurityTxtFoundError, parse_security_txt diff --git a/tests/unit/test_transaction.py b/tests/unit/test_transaction.py index 24088a0d..17bb82fa 100644 --- a/tests/unit/test_transaction.py +++ b/tests/unit/test_transaction.py @@ -2,7 +2,6 @@ from base64 import b64decode, b64encode import pytest -import solana.transaction as txlib import solders.system_program as sp from solders.hash import Hash as Blockhash from solders.instruction import AccountMeta, CompiledInstruction @@ -13,6 +12,8 @@ from solders.signature import Signature from solders.transaction import Transaction as SoldersTx +import solana.transaction as txlib + def example_tx(stubbed_blockhash, kp0: Keypair, kp1: Keypair, kp2: Keypair) -> txlib.Transaction: """Example tx for testing.""" diff --git a/tests/unit/test_vote_program.py b/tests/unit/test_vote_program.py index 4c1e3784..ec8c1a48 100644 --- a/tests/unit/test_vote_program.py +++ b/tests/unit/test_vote_program.py @@ -1,12 +1,13 @@ """Unit tests for solana.vote_program.""" import base64 -import solana.transaction as txlib -import solana.vote_program as vp from solders.hash import Hash from solders.keypair import Keypair from solders.pubkey import Pubkey +import solana.transaction as txlib +import solana.vote_program as vp + def test_withdraw_from_vote_account(): withdrawer_keypair = Keypair.from_bytes( diff --git a/tests/utils.py b/tests/utils.py index d08d419f..ab439a3d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,9 +1,10 @@ """Integration test utils.""" from typing import get_args +from solders.rpc.responses import RPCError, RPCResult + from solana.rpc.commitment import Processed from solana.rpc.types import TxOpts -from solders.rpc.responses import RPCError, RPCResult AIRDROP_AMOUNT = 10_000_000_000