From 39a7009133cd56035a2729ab3126fc78999ae1f9 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:33:42 +0200 Subject: [PATCH 1/6] test with python 3.12 --- .github/actions/prepare/action.yml | 2 +- .github/workflows/checks.yml | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/pypi.yaml | 2 +- .github/workflows/regtest.yml | 2 +- .github/workflows/tests.yml | 2 +- CONTRIBUTING.md | 2 +- Dockerfile | 2 +- README.md | 4 ++-- poetry.lock | 6 +++--- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml index 42e73610..0e1d915a 100644 --- a/.github/actions/prepare/action.yml +++ b/.github/actions/prepare/action.yml @@ -4,7 +4,7 @@ inputs: python-version: description: "Python Version" required: true - default: "3.10" + default: "3.12" poetry-version: description: "Poetry Version" default: "1.7.1" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7bb953d4..57102c75 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.10.4" + default: "3.12.3" type: string poetry-version: default: "1.7.1" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94f7254a..1b1cb265 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.10"] + python-version: ["3.12"] poetry-version: ["1.7.1"] mint-only-deprecated: ["false", "true"] mint-database: ["./test_data/test_mint", "postgres://cashu:cashu@localhost:5432/cashu"] @@ -30,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10"] + python-version: ["3.12"] poetry-version: ["1.7.1"] backend-wallet-class: ["LndRestWallet", "CLNRestWallet", "CoreLightningRestWallet", "LNbitsWallet"] diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 58775c3f..fcef9c41 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10"] + python-version: ["3.12"] poetry-version: ["1.7.1"] steps: - name: Checkout diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 63f33b8a..2b21aaa2 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.10.4" + default: "3.12.3" type: string poetry-version: default: "1.5.1" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0c1b83f..5ac8dd6b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.10.4" + default: "3.12.3" type: string poetry-version: default: "1.7.1" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f9f073a..57df7da9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ We use [Ruff](https://docs.astral.sh/ruff/formatter/) for formatting. To make su ## Setting up your environment -We use [Poetry](https://python-poetry.org/) as a dependency and environment manager. Currently, Nutshell supports Python `3.10.4` which you can install using `pyenv` (see README.md). To install all dependencies, run `poetry install`. After install, you can activate the shell with `poetry shell`. Now you can execute `cashu --help` to use the wallet or `mint` to run the mint. +We use [Poetry](https://python-poetry.org/) as a dependency and environment manager. Currently, Nutshell supports Python `3.12.3` which you can install using `pyenv` (see README.md). To install all dependencies, run `poetry install`. After install, you can activate the shell with `poetry shell`. Now you can execute `cashu --help` to use the wallet or `mint` to run the mint. ### Precommit hook To run the formatter and mypy (linter) before you push code, you can install the very useful pre-commit hook which will check your code every time you push with git. diff --git a/Dockerfile b/Dockerfile index da3eb565..c0b3d6e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-slim +FROM python:3.12-slim RUN apt-get update RUN apt-get install -y curl python3-dev autoconf g++ RUN apt-get install -y libpq-dev diff --git a/README.md b/README.md index 31ae820f..a8bc2141 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ curl https://pyenv.run | bash pyenv init # restart your shell (or source your .rc file), then install python: -pyenv install 3.10.4 +pyenv install 3.12.3 # install poetry curl -sSL https://install.python-poetry.org | python3 - @@ -92,7 +92,7 @@ source ~/.bashrc git clone https://github.com/cashubtc/nutshell.git cashu cd cashu git checkout -pyenv local 3.10.4 +pyenv local 3.12.3 poetry install ``` diff --git a/poetry.lock b/poetry.lock index 42edf8d4..2f28a5d7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -833,7 +833,7 @@ files = [ ] [package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} +zipp = {version = ">=3.1.0", markers = "python_version < \"3.12\""} [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] @@ -1565,7 +1565,7 @@ greenlet = {version = "!=0.4.17", optional = true, markers = "python_version >= [package.extras] aiomysql = ["aiomysql (>=0.2.0)", "greenlet (!=0.4.17)"] -aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing_extensions (!=3.10.0.1)"] +aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing_extensions (!=3.12.0.1)"] asyncio = ["greenlet (!=0.4.17)"] asyncmy = ["asyncmy (>=0.2.3,!=0.2.4)", "greenlet (!=0.4.17)"] mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2)"] @@ -1597,7 +1597,7 @@ files = [ [package.dependencies] anyio = ">=3.4.0,<5" -typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} +typing-extensions = {version = ">=3.12.0", markers = "python_version < \"3.12\""} [package.extras] full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyaml"] From 9fc7fe95c693f0a7a00c1c0ac8590ec970de5290 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:38:22 +0200 Subject: [PATCH 2/6] bump to 3.12.4 --- .github/workflows/checks.yml | 2 +- .github/workflows/regtest.yml | 2 +- .github/workflows/tests.yml | 2 +- CONTRIBUTING.md | 2 +- README.md | 4 ++-- pyproject.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 57102c75..68faa37b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.12.3" + default: "3.12.4" type: string poetry-version: default: "1.7.1" diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 2b21aaa2..68ee62ab 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.12.3" + default: "3.12.4" type: string poetry-version: default: "1.5.1" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ac8dd6b..8337b3ff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: python-version: - default: "3.12.3" + default: "3.12.4" type: string poetry-version: default: "1.7.1" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 57df7da9..b9170a69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ We use [Ruff](https://docs.astral.sh/ruff/formatter/) for formatting. To make su ## Setting up your environment -We use [Poetry](https://python-poetry.org/) as a dependency and environment manager. Currently, Nutshell supports Python `3.12.3` which you can install using `pyenv` (see README.md). To install all dependencies, run `poetry install`. After install, you can activate the shell with `poetry shell`. Now you can execute `cashu --help` to use the wallet or `mint` to run the mint. +We use [Poetry](https://python-poetry.org/) as a dependency and environment manager. Currently, Nutshell supports Python `3.12.4` which you can install using `pyenv` (see README.md). To install all dependencies, run `poetry install`. After install, you can activate the shell with `poetry shell`. Now you can execute `cashu --help` to use the wallet or `mint` to run the mint. ### Precommit hook To run the formatter and mypy (linter) before you push code, you can install the very useful pre-commit hook which will check your code every time you push with git. diff --git a/README.md b/README.md index a8bc2141..fef3fdf2 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ curl https://pyenv.run | bash pyenv init # restart your shell (or source your .rc file), then install python: -pyenv install 3.12.3 +pyenv install 3.12.4 # install poetry curl -sSL https://install.python-poetry.org | python3 - @@ -92,7 +92,7 @@ source ~/.bashrc git clone https://github.com/cashubtc/nutshell.git cashu cd cashu git checkout -pyenv local 3.12.3 +pyenv local 3.12.4 poetry install ``` diff --git a/pyproject.toml b/pyproject.toml index ca700550..04fb123b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["calle "] license = "MIT" [tool.poetry.dependencies] -python = "^3.8.1" +python = "^3.10" SQLAlchemy = {version = "1.4.52", extras = ["asyncio"]} click = "^8.1.7" pydantic = "^1.10.2" From 20923cbdd0c528ab8493053e3b491b1cfe856f33 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:42:56 +0200 Subject: [PATCH 3/6] ruff format --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 68faa37b..c3271235 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -52,3 +52,5 @@ jobs: steps: - uses: actions/checkout@v3 - uses: chartboost/ruff-action@v1 + with: + args: 'format --check' From 13bb5b90706f4a0a64f9c05f8c4c691de0efe05c Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:47:18 +0200 Subject: [PATCH 4/6] ruff format --- cashu/nostr/client/client.py | 22 ++++++++++++---------- cashu/nostr/event.py | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/cashu/nostr/client/client.py b/cashu/nostr/client/client.py index 3cb77662..3af7303b 100644 --- a/cashu/nostr/client/client.py +++ b/cashu/nostr/client/client.py @@ -45,9 +45,9 @@ def __init__(self, private_key: str = "", relays: List[str] = [], connect=True): def connect(self): for relay in self.relays: self.relay_manager.add_relay(relay) - self.relay_manager.open_connections({ - "cert_reqs": ssl.CERT_NONE - }) # NOTE: This disables ssl certificate verification + self.relay_manager.open_connections( + {"cert_reqs": ssl.CERT_NONE} + ) # NOTE: This disables ssl certificate verification def close(self): self.relay_manager.close_connections() @@ -105,13 +105,15 @@ def dm(self, message: str, to_pubkey: PublicKey): self.relay_manager.publish_event(dm) def get_dm(self, sender_publickey: PublicKey, callback_func=None, filter_kwargs={}): - filters = Filters([ - Filter( - kinds=[EventKind.ENCRYPTED_DIRECT_MESSAGE], - pubkey_refs=[sender_publickey.hex()], - **filter_kwargs, - ) - ]) + filters = Filters( + [ + Filter( + kinds=[EventKind.ENCRYPTED_DIRECT_MESSAGE], + pubkey_refs=[sender_publickey.hex()], + **filter_kwargs, + ) + ] + ) subscription_id = os.urandom(4).hex() self.relay_manager.add_subscription(subscription_id, filters) diff --git a/cashu/nostr/event.py b/cashu/nostr/event.py index 6271e7ef..0ee7ad0b 100644 --- a/cashu/nostr/event.py +++ b/cashu/nostr/event.py @@ -77,18 +77,20 @@ def verify(self) -> bool: ) def to_message(self) -> str: - return json.dumps([ - ClientMessageType.EVENT, - { - "id": self.id, - "pubkey": self.public_key, - "created_at": self.created_at, - "kind": self.kind, - "tags": self.tags, - "content": self.content, - "sig": self.signature, - }, - ]) + return json.dumps( + [ + ClientMessageType.EVENT, + { + "id": self.id, + "pubkey": self.public_key, + "created_at": self.created_at, + "kind": self.kind, + "tags": self.tags, + "content": self.content, + "sig": self.signature, + }, + ] + ) @dataclass From 76a36f929d4b3fa702955b865b66fce7d9268fa4 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:49:47 +0200 Subject: [PATCH 5/6] lock ruff version --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c3271235..7b9eab37 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -53,4 +53,5 @@ jobs: - uses: actions/checkout@v3 - uses: chartboost/ruff-action@v1 with: + version: 0.2.2 args: 'format --check' From 3627fbc96a09541fc8048893b594164bbd308e29 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:50:19 +0200 Subject: [PATCH 6/6] bump ruff version in pyproject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 04fb123b..bd7b7769 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ pytest = "^7.4.0" pre-commit = "^3.3.3" fastapi-profiler = "^1.2.0" respx = "^0.20.2" -ruff = "^0.2.1" +ruff = "^0.2.2" mypy = "^1.8.0" [build-system]