Skip to content

Commit

Permalink
chore: add pre-commit & format code (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat authored Aug 17, 2023
1 parent 131bb88 commit d6683b4
Show file tree
Hide file tree
Showing 163 changed files with 594 additions and 710 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on:
push:
pull_request:
branches-ignore:
- 'temp*'
- 'tmp*'
release:
types: [ created ]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/PyCQA/autoflake
rev: "v2.1.1"
hooks:
- id: autoflake
args: [--in-place, --ignore-init-module-imports, --remove-all-unused-imports]

- repo: https://github.com/pycqa/isort
rev: "5.11.5"
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.4.1'
hooks:
- id: mypy
additional_dependencies: [types-requests==2.31.0.2, types-toml==0.10.8.7, types-urllib3==1.26.25.14]
exclude: ^docs/
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ pypi:

clean:
find . -name \*.pyc -delete
rm -rf coverage.xml .coverage dist htmlcov stellar_sdk.egg-info tests/.mypy_cache tests/.pytest_cache docs/en/_build docs/zh_CN/_build
rm -rf coverage.xml .coverage dist htmlcov stellar_sdk.egg-info tests/.mypy_cache tests/.pytest_cache docs/en/_build docs/zh_CN/_build
.PHONY: clean

format:
autoflake --in-place --ignore-init-module-imports --remove-all-unused-imports stellar_sdk/**/*.py tests/**/*.py examples/*.py
isort stellar_sdk/**/*.py tests/**/*.py examples/*.py
black stellar_sdk/**/*.py tests/**/*.py examples/*.py
autoflake --in-place --ignore-init-module-imports --remove-all-unused-imports --recursive .
isort .
.PHONY: format

replace-xdr-keywords:
Expand Down
1 change: 0 additions & 1 deletion examples/manage_sell_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from stellar_sdk.asset import Asset
from stellar_sdk.keypair import Keypair
from stellar_sdk.network import Network
from stellar_sdk.operation.manage_sell_offer import ManageSellOffer
from stellar_sdk.server import Server
from stellar_sdk.transaction_builder import TransactionBuilder

Expand Down
2 changes: 1 addition & 1 deletion examples/soroban_auth_atomic_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import time

from stellar_sdk import Network, Keypair, TransactionBuilder, InvokeHostFunction
from stellar_sdk import InvokeHostFunction, Keypair, Network, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.authorization_entry import AuthorizationEntry
Expand Down
9 changes: 2 additions & 7 deletions examples/soroban_auth_with_stellar_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
"""
import time

from stellar_sdk import InvokeHostFunction
from stellar_sdk import (
Network,
Keypair,
TransactionBuilder,
)
from stellar_sdk import InvokeHostFunction, Keypair, Network, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.authorization_entry import AuthorizationEntry
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
from stellar_sdk.soroban.types import Uint32, Address
from stellar_sdk.soroban.types import Address, Uint32

rpc_server_url = "https://rpc-futurenet.stellar.org:443/"
soroban_server = SorobanServer(rpc_server_url)
Expand Down
8 changes: 2 additions & 6 deletions examples/soroban_auth_with_transaction_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
"""
import time

from stellar_sdk import (
Network,
Keypair,
TransactionBuilder,
)
from stellar_sdk import Keypair, Network, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
from stellar_sdk.soroban.types import Uint32, Address
from stellar_sdk.soroban.types import Address, Uint32

rpc_server_url = "https://rpc-futurenet.stellar.org:443/"
soroban_server = SorobanServer(rpc_server_url)
Expand Down
2 changes: 1 addition & 1 deletion examples/soroban_deploy_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
import time

from stellar_sdk import Network, Keypair, TransactionBuilder, StrKey
from stellar_sdk import Keypair, Network, StrKey, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
Expand Down
2 changes: 1 addition & 1 deletion examples/soroban_deploy_create_wrapped_token_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import time

from stellar_sdk import Network, Keypair, TransactionBuilder, Asset, StrKey
from stellar_sdk import Asset, Keypair, Network, StrKey, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
Expand Down
2 changes: 1 addition & 1 deletion examples/soroban_invoke_contract_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
import time

from stellar_sdk import Network, Keypair, TransactionBuilder
from stellar_sdk import Keypair, Network, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
Expand Down
2 changes: 1 addition & 1 deletion examples/soroban_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
import time

from stellar_sdk import Network, Keypair, TransactionBuilder
from stellar_sdk import Keypair, Network, TransactionBuilder
from stellar_sdk import xdr as stellar_xdr
from stellar_sdk.soroban import SorobanServer
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus
Expand Down
Loading

0 comments on commit d6683b4

Please sign in to comment.