Skip to content

Commit 8947efa

Browse files
committed
feat: code quality
1 parent 42a3dd0 commit 8947efa

File tree

19 files changed

+2872
-128
lines changed

19 files changed

+2872
-128
lines changed

.github/workflows/lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
uses: lnbits/lnbits/.github/workflows/lint.yml@dev

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
on:
22
push:
33
tags:
4-
- "v[0-9]+.[0-9]+.[0-9]+"
4+
- 'v[0-9]+.[0-9]+.[0-9]+'
55

66
jobs:
7-
87
release:
98
runs-on: ubuntu-latest
109
steps:
@@ -34,12 +33,12 @@ jobs:
3433
- name: Create pull request in extensions repo
3534
env:
3635
GH_TOKEN: ${{ secrets.EXT_GITHUB }}
37-
repo_name: "${{ github.event.repository.name }}"
38-
tag: "${{ github.ref_name }}"
39-
branch: "update-${{ github.event.repository.name }}-${{ github.ref_name }}"
40-
title: "[UPDATE] ${{ github.event.repository.name }} to ${{ github.ref_name }}"
41-
body: "https://github.com/lnbits/${{ github.event.repository.name }}/releases/${{ github.ref_name }}"
42-
archive: "https://github.com/lnbits/${{ github.event.repository.name }}/archive/refs/tags/${{ github.ref_name }}.zip"
36+
repo_name: '${{ github.event.repository.name }}'
37+
tag: '${{ github.ref_name }}'
38+
branch: 'update-${{ github.event.repository.name }}-${{ github.ref_name }}'
39+
title: '[UPDATE] ${{ github.event.repository.name }} to ${{ github.ref_name }}'
40+
body: 'https://github.com/lnbits/${{ github.event.repository.name }}/releases/${{ github.ref_name }}'
41+
archive: 'https://github.com/lnbits/${{ github.event.repository.name }}/archive/refs/tags/${{ github.ref_name }}.zip'
4342
run: |
4443
cd lnbits-extensions
4544
git checkout -b $branch

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
__pycache__
2+
node_modules
3+
.mypy_cache
4+
.venv

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"semi": false,
3+
"arrowParens": "avoid",
4+
"insertPragma": false,
5+
"printWidth": 80,
6+
"proseWrap": "preserve",
7+
"singleQuote": true,
8+
"trailingComma": "none",
9+
"useTabs": false,
10+
"bracketSameLine": false,
11+
"bracketSpacing": false
12+
}

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
all: format check
2+
3+
format: prettier black ruff
4+
5+
check: mypy pyright checkblack checkruff checkprettier
6+
7+
prettier:
8+
poetry run ./node_modules/.bin/prettier --write .
9+
pyright:
10+
poetry run ./node_modules/.bin/pyright
11+
12+
mypy:
13+
poetry run mypy .
14+
15+
black:
16+
poetry run black .
17+
18+
ruff:
19+
poetry run ruff check . --fix
20+
21+
checkruff:
22+
poetry run ruff check .
23+
24+
checkprettier:
25+
poetry run ./node_modules/.bin/prettier --check .
26+
27+
checkblack:
28+
poetry run black --check .
29+
30+
checkeditorconfig:
31+
editorconfig-checker
32+
33+
test:
34+
PYTHONUNBUFFERED=1 \
35+
DEBUG=true \
36+
poetry run pytest
37+
install-pre-commit-hook:
38+
@echo "Installing pre-commit hook to git"
39+
@echo "Uninstall the hook with poetry run pre-commit uninstall"
40+
poetry run pre-commit install
41+
42+
pre-commit:
43+
poetry run pre-commit run --all-files
44+
45+
46+
checkbundle:
47+
@echo "skipping checkbundle"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Invoices - <small>[LNbits](https://github.com/lnbits/lnbits) extension</small>
2+
23
<small>For more about LNBits extension check [this tutorial](https://github.com/lnbits/lnbits/wiki/LNbits-Extensions)</small>
34

45
## Create invoices that you can send to your client to pay online over Lightning.

__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ def invoices_renderer():
3232

3333
scheduled_tasks: list[asyncio.Task] = []
3434

35+
3536
def invoices_stop():
3637
for task in scheduled_tasks:
3738
try:
3839
task.cancel()
3940
except Exception as ex:
4041
logger.warning(ex)
4142

43+
4244
def invoices_start():
4345
task = create_permanent_unique_task("ext_invoices", wait_for_paid_invoices)
4446
scheduled_tasks.append(task)

crud.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,35 +146,30 @@ async def update_invoice_internal(
146146
assert invoice, "Newly updated invoice couldn't be retrieved"
147147
return invoice
148148

149+
149150
async def delete_invoice(
150-
invoice_id: str,
151+
invoice_id: str,
151152
) -> bool:
152153
await db.execute(
153154
f"""
154155
DELETE FROM invoices.payments
155156
WHERE invoice_id = ?
156157
""",
157-
(
158-
invoice_id,
159-
),
158+
(invoice_id,),
160159
)
161160
await db.execute(
162161
f"""
163162
DELETE FROM invoices.invoice_items
164163
WHERE invoice_id = ?
165164
""",
166-
(
167-
invoice_id,
168-
),
165+
(invoice_id,),
169166
)
170167
await db.execute(
171168
f"""
172169
DELETE FROM invoices.invoices
173170
WHERE id = ?
174171
""",
175-
(
176-
invoice_id,
177-
),
172+
(invoice_id,),
178173
)
179174
return True
180175

manifest.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"repos": [
3-
{
4-
"id": "invoices",
5-
"organisation": "lnbits",
6-
"repository": "invoices"
7-
}
8-
]
2+
"repos": [
3+
{
4+
"id": "invoices",
5+
"organisation": "lnbits",
6+
"repository": "invoices"
7+
}
8+
]
99
}

package-lock.json

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)