Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 92
per-file-ignores =
__init__.py: E402
27 changes: 27 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: flake8

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
poetry-version: ['1.3.1']
steps:
- uses: actions/checkout@v3
- name: Set up Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: |
poetry install
- name: Run tests
run: make flake8
33 changes: 33 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: formatting

on: [push, pull_request]

jobs:
checks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
poetry-version: ['1.3.1']
steps:
- uses: actions/checkout@v3
- name: Set up Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install packages
run: |
poetry install
npm install
- name: Check black
run: make checkblack
- name: Check isort
run: make checkisort
- uses: actions/setup-node@v3
- name: Check prettier
run: make checkprettier
27 changes: 27 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: mypy

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
poetry-version: ['1.3.1']
steps:
- uses: actions/checkout@v3
- name: Set up Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: |
poetry install
- name: Run tests
run: make mypy
27 changes: 27 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pylint

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
poetry-version: ['1.3.1']
steps:
- uses: actions/checkout@v3
- name: Set up Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: |
poetry install
- name: Run tests
run: make pylint
28 changes: 28 additions & 0 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: pyright

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
poetry-version: ['1.3.1']
steps:
- uses: actions/checkout@v3
- name: Set up Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: |
poetry install
npm install
- name: Run tests
run: make pyright
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release github version
on:
push:
tags:
- "[0-9]+.[0-9]+"
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
node_modules
.mypy_cache
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"semi": false,
"arrowParens": "avoid",
"insertPragma": false,
"printWidth": 80,
"proseWrap": "preserve",
"singleQuote": true,
"trailingComma": "none",
"useTabs": false,
"bracketSameLine": false,
"bracketSpacing": false
}
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
all: format check

format: prettier isort black

check: pyright pylint flake8 checkisort checkblack checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write config.json manifest.json static templates

pyright:
poetry run ./node_modules/.bin/pyright

black:
poetry run black .

flake8:
poetry run flake8

mypy:
poetry run mypy

isort:
poetry run isort .

pylint:
poetry run pylint *.py

checkprettier:
poetry run ./node_modules/.bin/prettier --check config.json manifest.json static templates

checkblack:
poetry run black --check .

checkisort:
poetry run isort --check-only .

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry run pytest
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This is an example extension to help you organise and build you own.
Try to include an image
<img src="https://i.imgur.com/9i4xcQB.png">


<h2>If your extension has API endpoints, include useful ones here</h2>

<code>curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"example"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"</code>
9 changes: 6 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
from typing import List

from fastapi import APIRouter
from fastapi.staticfiles import StaticFiles

from lnbits.db import Database
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart
Expand All @@ -11,6 +11,8 @@

example_ext: APIRouter = APIRouter(prefix="/example", tags=["example"])

scheduled_tasks: List[asyncio.Task] = []

example_static_files = [
{
"path": "/example/static",
Expand All @@ -29,6 +31,7 @@ def example_renderer():
from .views_api import * # noqa: F401,F403


def tpos_start():
def example_start():
loop = asyncio.get_event_loop()
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
task = loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
scheduled_tasks.append(task)
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Build your own!",
"short_description": "Extension building guide",
"tile": "/example/static/bitcoin-extension.png",
"tile": "/example/static/bitcoin-extension.png",
"contributors": ["github_username"]
}
2 changes: 1 addition & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# add your dependencies here

# add your fnctions here
# add your functions here
14 changes: 7 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"repos": [
{
"id": "example",
"organisation": "lnbits",
"repository": "example"
}
]
"repos": [
{
"id": "example",
"organisation": "lnbits",
"repository": "example"
}
]
}
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "example",
"dependencies": {
"prettier": "^2.8.7",
"pyright": "^1.1.303"
}
}
Loading