Skip to content
Merged
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
34 changes: 0 additions & 34 deletions .github/workflows/ci.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: lint
on:
push:
branches:
- main
pull_request:

jobs:
lint:
uses: lnbits/lnbits/.github/workflows/lint.yml@dev
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create github release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -19,7 +19,7 @@ jobs:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.EXT_GITHUB }}
repository: lnbits/lnbits-extensions
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ format: prettier black ruff
check: mypy pyright checkblack checkruff checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write .
uv run ./node_modules/.bin/prettier --write .
pyright:
poetry run ./node_modules/.bin/pyright
uv run ./node_modules/.bin/pyright

mypy:
poetry run mypy .
uv run mypy .

black:
poetry run black .
uv run black .

ruff:
poetry run ruff check . --fix
uv run ruff check . --fix

checkruff:
poetry run ruff check .
uv run ruff check .

checkprettier:
poetry run ./node_modules/.bin/prettier --check .
uv run ./node_modules/.bin/prettier --check .

checkblack:
poetry run black --check .
uv run black --check .

checkeditorconfig:
editorconfig-checker

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry run pytest
uv run pytest
install-pre-commit-hook:
@echo "Installing pre-commit hook to git"
@echo "Uninstall the hook with poetry run pre-commit uninstall"
poetry run pre-commit install
@echo "Uninstall the hook with uv run pre-commit uninstall"
uv run pre-commit install

pre-commit:
poetry run pre-commit run --all-files
uv run pre-commit run --all-files


checkbundle:
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def myextension_start():
__all__ = [
"db",
"myextension_ext",
"myextension_static_files",
"myextension_start",
"myextension_static_files",
"myextension_stop",
]
5 changes: 2 additions & 3 deletions crud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Description: This file contains the CRUD operations for talking to the database.

from typing import List, Optional, Union

from lnbits.db import Database
from lnbits.helpers import urlsafe_short_hash
Expand All @@ -16,15 +15,15 @@ async def create_myextension(data: CreateMyExtensionData) -> MyExtension:
return MyExtension(**data.dict())


async def get_myextension(myextension_id: str) -> Optional[MyExtension]:
async def get_myextension(myextension_id: str) -> MyExtension | None:
return await db.fetchone(
"SELECT * FROM myextension.maintable WHERE id = :id",
{"id": myextension_id},
MyExtension,
)


async def get_myextensions(wallet_ids: Union[str, List[str]]) -> List[MyExtension]:
async def get_myextensions(wallet_ids: str | list[str]) -> list[MyExtension]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]
q = ",".join([f"'{w}'" for w in wallet_ids])
Expand Down
7 changes: 3 additions & 4 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Description: Pydantic data models dictate what is passed between frontend and backend.

from typing import Optional

from pydantic import BaseModel


class CreateMyExtensionData(BaseModel):
id: Optional[str] = ""
id: str | None = ""
name: str
lnurlpayamount: int
lnurlwithdrawamount: int
Expand All @@ -21,8 +20,8 @@ class MyExtension(BaseModel):
lnurlwithdrawamount: int
wallet: str
total: int
lnurlpay: Optional[str] = ""
lnurlwithdraw: Optional[str] = ""
lnurlpay: str | None = ""
lnurlwithdraw: str | None = ""


class CreatePayment(BaseModel):
Expand Down
2,630 changes: 0 additions & 2,630 deletions poetry.lock

This file was deleted.

56 changes: 33 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
[tool.poetry]
[project]
name = "myextension"
version = "0.0.0"
requires-python = ">=3.10,<3.13"
description = "Eightball is a simple API that allows you to create a random number generator."
authors = ["benarc", "dni <dni@lnbits.com>"]
authors = [{name = "benarc"}, {name = "dni", email = "dni@lnbits.com"}]

[tool.poetry.dependencies]
python = "^3.10 | ^3.9"
lnbits = {version = "*", allow-prereleases = true}
mypy = "^1.13.0"
dependencies = [ "lnbits>1" ]

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
pytest-asyncio = "^0.21.0"
pytest = "^7.3.2"
mypy = "^1.5.1"
pre-commit = "^3.2.2"
ruff = "^0.3.2"
pytest-md = "^0.2.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = [
"black",
"pytest-asyncio",
"pytest",
"mypy",
"pre-commit",
"ruff",
]

[tool.mypy]
exclude = "(nostr/*)"
plugins = ["pydantic.mypy"]

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true

[[tool.mypy.overrides]]
module = [
"lnbits.*",
"lnurl.*",
"loguru.*",
"fastapi.*",
"pydantic.*",
"pyqrcode.*",
"shortuuid.*",
"httpx.*",
]
ignore_missing_imports = "True"

Expand All @@ -44,7 +52,9 @@ line-length = 88
[tool.ruff]
# Same as Black. + 10% rule of black
line-length = 88

exclude = [
"nostr",
]

[tool.ruff.lint]
# Enable:
Expand All @@ -59,8 +69,7 @@ line-length = 88
# RUF - ruff
# B - bugbear
select = ["F", "E", "W", "I", "A", "C", "N", "UP", "RUF", "B"]
# UP007: pyupgrade: use X | Y instead of Optional. (python3.10)
ignore = ["UP007"]
ignore = ["C901"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
Expand All @@ -72,12 +81,13 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# needed for pydantic
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"validator",
"root_validator",
]

# Ignore unused imports in __init__.py files.
# [tool.ruff.lint.extend-per-file-ignores]
# "views_api.py" = ["F401"]
# "__init__.py" = ["F401", "F403"]

# [tool.ruff.lint.mccabe]
# max-complexity = 10
Expand All @@ -87,4 +97,4 @@ classmethod-decorators = [
extend-immutable-calls = [
"fastapi.Depends",
"fastapi.Query",
]
]
Loading