Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
985480a
Run ruff in CI
sterliakov Jul 1, 2025
69fe270
Apply autofixes
sterliakov Jul 1, 2025
227b9cd
Reuse RPC methods in tests
sterliakov Jul 1, 2025
c5b8455
Minimally wrap lines in test code
sterliakov Jul 1, 2025
95180ea
Wrap docstrings that do not fit even 127 chars
sterliakov Jul 1, 2025
8718b62
Add explicit imports to reference `__all__` on
sterliakov Jul 1, 2025
a01c8bc
Reload docs when docstrings change
sterliakov Jul 1, 2025
0aff020
Python 3.7 is EOL for so long that it is out of support on 24.04
sterliakov Jul 1, 2025
04fbf4d
Add fake temporary tag for running tests
sterliakov Jul 1, 2025
b66a7ae
Move linter config to pre-commit for reproducibility
sterliakov Jul 1, 2025
acf08bc
Rename ruff.toml in examples
sterliakov Jul 1, 2025
558f157
Rework release workflow to separate check and deploy steps
sterliakov Jul 1, 2025
1886a4e
Print verbose pre-commit output for PRs
sterliakov Jul 1, 2025
41bdcbc
Remove zizmor for now
sterliakov Jul 1, 2025
8d0da54
Add basic docs checking job
sterliakov Jul 1, 2025
fc09b84
Enhance release workflow, set to testpypi to check
sterliakov Jul 1, 2025
59704da
Revert wrongly reused methods set
sterliakov Jul 1, 2025
1bc8606
Alter name temporarily to show upload
sterliakov Jul 1, 2025
aeb5383
Wrong name. missed stderr
sterliakov Jul 1, 2025
9809f59
Unset `-e` - we need to capture the exit code
sterliakov Jul 1, 2025
b80e316
Patch a package that has better testpypi target
sterliakov Jul 1, 2025
44b4ca9
Back to production deployment
sterliakov Jul 3, 2025
04548f5
Update pre-commit hooks
sterliakov Jul 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 71 additions & 15 deletions .github/workflows/deploypypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,93 @@ on:
release:
types: [created]

permissions:
contents: read

jobs:
deploy:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install project dependencies

- name: Lint and format code with pre-commit
uses: pre-commit/action@v3.0.1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install -e .
pip install -r requirements-test.txt
- name: Test with pytest
run: |
pip install pytest
pytest

publish:
runs-on: ubuntu-latest
needs: [check]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install deploy dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
twine upload dist/* --verbose

check-released:
runs-on: ubuntu-latest
needs: [publish]
timeout-minutes: 10
steps:
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install and import the uploaded package
run: |
python -m pip install --upgrade pip
set +e
while true; do
log=$(
2>&1 python -m pip install \
"substrate-interface==${GITHUB_REF#refs/tags/v}"
)
status=$?
if [ "$status" = 0 ]; then
echo "Installed successfully."
break
elif grep -q 'Could not find a version' <<<"$log"; then
echo "Waiting for release to propagate to the index..."
sleep 5
else
echo '::error::Unexpected output from "pip install", release seems to have failed.'
cat <<<"$log"
exit 1
fi
done

if ! python -c 'import substrateinterface'; then
echo '::error::Unable to import the installed package!'
exit 2
fi
59 changes: 45 additions & 14 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,64 @@ on:
schedule:
- cron: '0 7 * * *'

jobs:
build:
permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Lint and format code with pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files -v

test:
runs-on: ${{ matrix.python-version == '3.7' && 'ubuntu-22.04' || 'ubuntu-latest' }}
strategy:
matrix:
python-version: [3.12]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
CI_COMMIT_TAG="v0.0.1+$(git rev-parse HEAD)" pip install -e .
pip install -r requirements-test.txt
- name: Test with pytest
run: |
pip install pytest
pytest

check-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Check documentation build
run: |
pip install -r requirements-docs.txt
# TODO: Enable when documentation is fixed
mkdocs build # --strict
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is only a stub, other hooks will land later

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.3
hooks:
# Disabled until next PR
# - id: ruff-format
- id: ruff-check
args: [--fix]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.2
hooks:
- id: check-github-workflows

- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
additional_dependencies:
- github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Overview of available [extensions](/extensions/); adding or improving existing f
## Metadata docs
[Documentation of Substrate metadata](https://polkascan.github.io/py-substrate-metadata-docs/) for well known runtimes and how to use it with py-substrate-interface.

## Contact and Support
## Contact and Support

For questions, please see the [Substrate StackExchange](https://substrate.stackexchange.com/questions/tagged/python), [Github Discussions](https://github.com/polkascan/py-substrate-interface/discussions) or
reach out to us on our [matrix](http://matrix.org) chat group: [Polkascan Technical](https://matrix.to/#/#polkascan:matrix.org).
Expand Down
3 changes: 3 additions & 0 deletions examples/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Prefer human-readable line length and non-eol python for examples
target-version = "py39"
line-length = 88
2 changes: 1 addition & 1 deletion examples/extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timedelta
from datetime import datetime

from substrateinterface import SubstrateInterface
from substrateinterface.extensions import SubstrateNodeExtension
Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ markdown_extensions:
- pymdownx.snippets
- pymdownx.superfences

watch:
- docs
- substrateinterface
- mkdocs.yml
5 changes: 5 additions & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdocs
mkdocs-material
mkdocs-autorefs
mkdocstrings
mkdocstrings[python]
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest>=4.4.0
23 changes: 0 additions & 23 deletions requirements.txt

This file was deleted.

21 changes: 21 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
target-version = "py37"
line-length = 127

[analyze]
detect-string-imports = true

[format]
docstring-code-format = true

[lint]
# Minimal for now; more rules are needed
select = ["E", "F"]

[lint.per-file-ignores]
"test/fixtures.py" = [
# Giant blobs
"E501"
]
"**/__init__.py" = [
"F403", # Allow star imports for reexport
]
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
# Python 3 only projects can skip this import
from io import open

# FIXME: this should never be used, version shouldn't be resolved at runtime,
# it has to be shipped with the package. When this is gone, remove workaround
# from unittests.yml workflow.
if environ.get('TRAVIS_TAG'):
version = environ['TRAVIS_TAG'].replace('v', '')
elif environ.get('CI_COMMIT_TAG'):
Expand Down
1 change: 1 addition & 0 deletions substrateinterface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from . import base, contracts, keypair, interfaces, extensions
from .base import *
from .contracts import *
from .keypair import *
Expand Down
Loading