diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4d93d50 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint + +on: + push: + branches: + - "master" + - "develop" + pull_request: + types: [ready_for_review, synchronize, opened] + +jobs: + flake8: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v7 + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version: "3.14" + - name: install dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install .[test] + - name: run linter + run: | + . venv/bin/activate + make lint diff --git a/client/client.py b/client/client.py index b1120b8..a9039a7 100644 --- a/client/client.py +++ b/client/client.py @@ -4,9 +4,9 @@ from pathlib import Path from client.connection import Connection -from client.exceptions import ArkParameterException from client.resource import Resource + class ArkClient(object): def __init__(self, hostname): diff --git a/client/connection.py b/client/connection.py index 30d52a8..fd6b4da 100644 --- a/client/connection.py +++ b/client/connection.py @@ -1,8 +1,9 @@ import backoff + import requests -from client.exceptions import ArkHTTPException, ArkParameterException +from client.exceptions import ArkHTTPException def giveup_handler(_): diff --git a/client/resource.py b/client/resource.py index 34fa136..5b58fe7 100644 --- a/client/resource.py +++ b/client/resource.py @@ -1,5 +1,6 @@ from flatten_dict import flatten + class Resource(object): def __init__(self, connection): diff --git a/setup.cfg b/setup.cfg index dded69d..412908a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,7 @@ [flake8] max-line-length = 100 application-import-names = client +extend-exclude = .venv,venv,build,dist [tool:pytest] addopts = --verbose -s diff --git a/tests/api/test_blocks.py b/tests/api/test_blocks.py index 4ff7df0..de4555e 100644 --- a/tests/api/test_blocks.py +++ b/tests/api/test_blocks.py @@ -1,5 +1,3 @@ -import json - import responses from client import ArkClient @@ -44,7 +42,7 @@ def test_all_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.blocks.all(page=5, limit=69, orderBy="timestamp.epoch", height=6838329) + client.blocks.all(page=5, limit=69, orderBy='timestamp.epoch', height=6838329) assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/blocks?') assert 'page=5' in responses.calls[0].request.url diff --git a/tests/api/test_delegates.py b/tests/api/test_delegates.py index ad19b05..351d141 100644 --- a/tests/api/test_delegates.py +++ b/tests/api/test_delegates.py @@ -1,5 +1,3 @@ -import json - import responses from client import ArkClient @@ -44,7 +42,7 @@ def test_all_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.delegates.all(page=5, limit=69, orderBy="username") + client.delegates.all(page=5, limit=69, orderBy='username') assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/delegates?') assert 'page=5' in responses.calls[0].request.url diff --git a/tests/api/test_locks.py b/tests/api/test_locks.py index 58bfbad..05cd3cf 100644 --- a/tests/api/test_locks.py +++ b/tests/api/test_locks.py @@ -44,7 +44,7 @@ def test_all_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.locks.all(page=5, limit=69, orderBy="id") + client.locks.all(page=5, limit=69, orderBy='id') assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/locks?') assert 'page=5' in responses.calls[0].request.url diff --git a/tests/api/test_node.py b/tests/api/test_node.py index e241b75..3fb9204 100644 --- a/tests/api/test_node.py +++ b/tests/api/test_node.py @@ -58,6 +58,7 @@ def test_configuration_crypto_call_correct_url(): assert len(responses.calls) == 1 assert responses.calls[0].request.url == 'http://127.0.0.1:4002/node/configuration/crypto' + def test_fees_calls_correct_url(): responses.add( responses.GET, diff --git a/tests/api/test_rounds.py b/tests/api/test_rounds.py index 7a156be..4a357ee 100644 --- a/tests/api/test_rounds.py +++ b/tests/api/test_rounds.py @@ -1,5 +1,3 @@ -import json - import responses from client import ArkClient diff --git a/tests/api/test_transactions.py b/tests/api/test_transactions.py index c055cb6..3055235 100644 --- a/tests/api/test_transactions.py +++ b/tests/api/test_transactions.py @@ -44,7 +44,7 @@ def test_all_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.transactions.all(page=5, limit=69, orderBy="timestamp.epoch") + client.transactions.all(page=5, limit=69, orderBy='timestamp.epoch') assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/transactions?') assert 'page=5' in responses.calls[0].request.url @@ -128,9 +128,11 @@ def test_all_unconfirmed_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.transactions.all_unconfirmed(page=5, limit=69, orderBy="timestamp.epoch") + client.transactions.all_unconfirmed(page=5, limit=69, orderBy='timestamp.epoch') assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/transactions/unconfirmed?') + assert responses.calls[0].request.url.startswith( + 'http://127.0.0.1:4002/transactions/unconfirmed?' + ) assert 'page=5' in responses.calls[0].request.url assert 'limit=69' in responses.calls[0].request.url assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url diff --git a/tests/api/test_wallets.py b/tests/api/test_wallets.py index 033a5f6..f98b31a 100644 --- a/tests/api/test_wallets.py +++ b/tests/api/test_wallets.py @@ -1,5 +1,3 @@ -import json - import responses from client import ArkClient @@ -108,7 +106,7 @@ def test_locks_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.wallets.locks(wallet_id=wallet_id, page=5, limit=69, orderBy="timestamp.epoch") + client.wallets.locks(wallet_id=wallet_id, page=5, limit=69, orderBy='timestamp.epoch') assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/wallets/12345/locks?') assert 'page=5' in responses.calls[0].request.url @@ -162,9 +160,11 @@ def test_transactions_calls_correct_url_with_additional_params(): ) client = ArkClient('http://127.0.0.1:4002') - client.wallets.transactions(wallet_id=wallet_id, page=5, limit=69, orderBy="timestamp.epoch") + client.wallets.transactions(wallet_id=wallet_id, page=5, limit=69, orderBy='timestamp.epoch') assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/wallets/12345/transactions?') + assert responses.calls[0].request.url.startswith( + 'http://127.0.0.1:4002/wallets/12345/transactions?' + ) assert 'page=5' in responses.calls[0].request.url assert 'limit=69' in responses.calls[0].request.url assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url diff --git a/tests/test_client.py b/tests/test_client.py index 33681b8..18b4592 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,5 +1,3 @@ -import pytest - from client.client import ArkClient from client.connection import Connection diff --git a/tests/test_connection.py b/tests/test_connection.py index 5e261af..e803355 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -61,7 +61,7 @@ def test_connection_raises_for_request_retry_failure(): connection = Connection('http://127.0.0.1:4003') - with pytest.raises(ArkHTTPException) as exception: + with pytest.raises(ArkHTTPException): connection.get('spongebob') assert len(responses.calls) == 3 diff --git a/tests/test_resource.py b/tests/test_resource.py index 8b22eec..264d933 100644 --- a/tests/test_resource.py +++ b/tests/test_resource.py @@ -20,4 +20,3 @@ def test_request_post_calls_connection_post_with_correct_params(mocker): resource.request_post('spongebob', data={'one': 'two'}, params={'foo': 'bar'}) post_mock.assert_called_once_with('spongebob', data={'one': 'two'}, params={'foo': 'bar'}) -