Skip to content

Commit

Permalink
chore: mypy and ruff tweaks wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Dec 10, 2024
1 parent aad3ca1 commit 8f49afc
Show file tree
Hide file tree
Showing 46 changed files with 214 additions and 462 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
# stop the build if there are files that don't meet formatting requirements
poetry run ruff format --check .
- name: Check linting with Ruff
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run ruff check .
# - name: Check linting with Ruff
# run: |
# # stop the build if there are Python syntax errors or undefined names
# poetry run ruff check .

- name: Check types with mypy
run: poetry run mypy
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ repos:
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
files: "^(src|tests)/"
exclude: "^tests/artifacts/"
1 change: 0 additions & 1 deletion legacy_v2_tests/test_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import TYPE_CHECKING

from algokit_utils import get_account

from legacy_v2_tests.conftest import get_unique_name

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions legacy_v2_tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from algokit_utils import AppDeployMetaData


Expand Down
1 change: 1 addition & 0 deletions legacy_v2_tests/test_app_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from algokit_utils import (
DeploymentFailedError,
get_next_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Txn {txn} had error 'assert failed pc=743' at PC 743:

Could not determine TEAL source line for the error as no approval source map was provided, to receive a trace of the
error please provide an approval SourceMap. Either by:
1.Providing template_values when creating the ApplicationClient, so a SourceMap can be obtained automatically OR
2.Set approval_source_map from a previously compiled approval program OR
3.Import a previously exported source map using import_source_map
1. Providing template_values when creating the ApplicationClient, so a SourceMap can be obtained automatically OR
2. Set approval_source_map from a previously compiled approval program OR
3. Import a previously exported source map using import_source_map
4 changes: 2 additions & 2 deletions legacy_v2_tests/test_app_client_clear_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
ApplicationClient,
ApplicationSpecification,
)

from legacy_v2_tests.conftest import is_opted_in

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient


@pytest.fixture()
@pytest.fixture
def client_fixture(
algod_client: "AlgodClient",
indexer_client: "IndexerClient",
Expand Down
4 changes: 2 additions & 2 deletions legacy_v2_tests/test_app_client_close_out.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
ApplicationClient,
ApplicationSpecification,
LogicError,
)

from legacy_v2_tests.conftest import check_output_stability, is_opted_in

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient


@pytest.fixture()
@pytest.fixture
def client_fixture(
algod_client: "AlgodClient",
indexer_client: "IndexerClient",
Expand Down
6 changes: 3 additions & 3 deletions legacy_v2_tests/test_app_client_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from typing import TYPE_CHECKING

import pytest
from algosdk.atomic_transaction_composer import AccountTransactionSigner, AtomicTransactionComposer, TransactionSigner
from algosdk.transaction import ApplicationCallTxn, GenericSignedTransaction, OnComplete, Transaction

from algokit_utils import (
Account,
ApplicationClient,
Expand All @@ -10,9 +13,6 @@
get_account,
get_app_id_from_tx_id,
)
from algosdk.atomic_transaction_composer import AccountTransactionSigner, AtomicTransactionComposer, TransactionSigner
from algosdk.transaction import ApplicationCallTxn, GenericSignedTransaction, OnComplete, Transaction

from legacy_v2_tests.conftest import check_output_stability, get_unique_name

if TYPE_CHECKING:
Expand Down
4 changes: 2 additions & 2 deletions legacy_v2_tests/test_app_client_delete.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
ApplicationClient,
ApplicationSpecification,
LogicError,
)

from legacy_v2_tests.conftest import check_output_stability

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient


@pytest.fixture()
@pytest.fixture
def client_fixture(
algod_client: "AlgodClient",
indexer_client: "IndexerClient",
Expand Down
4 changes: 2 additions & 2 deletions legacy_v2_tests/test_app_client_deploy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
ABICreateCallArgs,
Account,
Expand All @@ -9,15 +10,14 @@
TransferParameters,
transfer,
)

from legacy_v2_tests.conftest import get_unique_name, read_spec

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient


@pytest.fixture()
@pytest.fixture
def client_fixture(
algod_client: "AlgodClient",
indexer_client: "IndexerClient",
Expand Down
4 changes: 2 additions & 2 deletions legacy_v2_tests/test_app_client_opt_in.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
ApplicationClient,
ApplicationSpecification,
LogicError,
)

from legacy_v2_tests.conftest import check_output_stability, is_opted_in

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient


@pytest.fixture()
@pytest.fixture
def client_fixture(
algod_client: "AlgodClient",
indexer_client: "IndexerClient",
Expand Down
3 changes: 2 additions & 1 deletion legacy_v2_tests/test_app_client_prepare.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import base64
from typing import TYPE_CHECKING

from algosdk.atomic_transaction_composer import AccountTransactionSigner

from algokit_utils import (
ApplicationClient,
ApplicationSpecification,
)
from algosdk.atomic_transaction_composer import AccountTransactionSigner

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
Expand Down
1 change: 0 additions & 1 deletion legacy_v2_tests/test_app_client_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
ApplicationClient,
DefaultArgumentDict,
)

from legacy_v2_tests.conftest import read_spec

if TYPE_CHECKING:
Expand Down
5 changes: 3 additions & 2 deletions legacy_v2_tests/test_app_client_signer_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from typing import TYPE_CHECKING, Any

import pytest
from algosdk.atomic_transaction_composer import AccountTransactionSigner, TransactionSigner

from algokit_utils import (
ApplicationClient,
ApplicationSpecification,
get_sender_from_signer,
)
from algosdk.atomic_transaction_composer import AccountTransactionSigner, TransactionSigner

if TYPE_CHECKING:
from algosdk import transaction
Expand All @@ -30,7 +31,7 @@ def sign_transactions(
@pytest.mark.parametrize("override_signer", [CustomSigner(), AccountTransactionSigner(fake_key), None])
@pytest.mark.parametrize("default_sender", ["default_sender", None])
@pytest.mark.parametrize("default_signer", [CustomSigner(), AccountTransactionSigner(fake_key), None])
def test_resolve_signer_sender( # noqa: PLR0913
def test_resolve_signer_sender(
*,
algod_client: "AlgodClient",
app_spec: ApplicationSpecification,
Expand Down
2 changes: 1 addition & 1 deletion legacy_v2_tests/test_app_client_template_values.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import TYPE_CHECKING

import algokit_utils
import pytest

import algokit_utils
from legacy_v2_tests.conftest import get_unique_name, read_spec

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion legacy_v2_tests/test_app_client_update.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
ApplicationClient,
ApplicationSpecification,
LogicError,
)

from legacy_v2_tests.conftest import check_output_stability

if TYPE_CHECKING:
Expand Down
3 changes: 2 additions & 1 deletion legacy_v2_tests/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import TYPE_CHECKING

import pytest

from algokit_utils import (
Account,
EnsureBalanceParameters,
Expand All @@ -19,7 +20,7 @@
from legacy_v2_tests.conftest import assure_funds, generate_test_asset, get_unique_name


@pytest.fixture()
@pytest.fixture
def to_account(kmd_client: "KMDClient") -> Account:
return create_kmd_wallet_account(kmd_client, get_unique_name())

Expand Down
16 changes: 8 additions & 8 deletions legacy_v2_tests/test_debug_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
from unittest.mock import Mock

import pytest
from algosdk.atomic_transaction_composer import (
AccountTransactionSigner,
AtomicTransactionComposer,
TransactionWithSigner,
)
from algosdk.transaction import PaymentTxn

from algokit_utils._debugging import (
AVMDebuggerSourceMap,
PersistSourceMapInput,
Expand All @@ -14,20 +21,13 @@
from algokit_utils.application_specification import ApplicationSpecification
from algokit_utils.common import Program
from algokit_utils.models import Account
from algosdk.atomic_transaction_composer import (
AccountTransactionSigner,
AtomicTransactionComposer,
TransactionWithSigner,
)
from algosdk.transaction import PaymentTxn

from legacy_v2_tests.conftest import check_output_stability, get_unique_name

if TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient


@pytest.fixture()
@pytest.fixture
def client_fixture(algod_client: "AlgodClient", app_spec: ApplicationSpecification) -> ApplicationClient:
creator_name = get_unique_name()
creator = get_account(algod_client, creator_name)
Expand Down
1 change: 0 additions & 1 deletion legacy_v2_tests/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
replace_template_variables,
)
from algokit_utils._legacy_v2.deploy import strip_comments

from legacy_v2_tests.conftest import check_output_stability


Expand Down
8 changes: 4 additions & 4 deletions legacy_v2_tests/test_deploy_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from unittest.mock import Mock, patch

import pytest

from algokit_utils import (
Account,
ApplicationClient,
Expand All @@ -19,7 +20,6 @@
get_indexer_client,
get_localnet_default_account,
)

from legacy_v2_tests.conftest import check_output_stability, get_specs, get_unique_name, read_spec

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(
self.creator = creator
self.app_name = get_unique_name()

def deploy( # noqa: PLR0913
def deploy(
self,
app_spec: ApplicationSpecification,
*,
Expand Down Expand Up @@ -128,12 +128,12 @@ def creator(creator_name: str) -> Account:
return get_account(get_algod_client(), creator_name)


@pytest.fixture()
@pytest.fixture
def app_name() -> str:
return get_unique_name()


@pytest.fixture()
@pytest.fixture
def deploy_fixture(
caplog: pytest.LogCaptureFixture, request: pytest.FixtureRequest, creator_name: str, creator: Account
) -> DeployFixture:
Expand Down
3 changes: 2 additions & 1 deletion legacy_v2_tests/test_dispenser_api_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import json

import pytest
from pytest_httpx import HTTPXMock

from algokit_utils.dispenser_api import (
DISPENSER_ASSETS,
DispenserApiConfig,
DispenserAssetName,
TestNetDispenserApiClient,
)
from pytest_httpx import HTTPXMock


class TestDispenserApiTestnetClient:
Expand Down
Loading

0 comments on commit 8f49afc

Please sign in to comment.