From a0739d29fb9b2e1e0cdf31d59c2d19dfdf18b088 Mon Sep 17 00:00:00 2001 From: Shroominic Date: Thu, 5 Jun 2025 13:22:59 +0200 Subject: [PATCH] fix linting errors --- router/cashu.py | 2 -- router/discovery.py | 2 +- router/proxy.py | 2 -- tests/conftest.py | 1 - tests/test_account.py | 5 ++--- tests/test_models.py | 2 +- tests/test_proxy.py | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/router/cashu.py b/router/cashu.py index 713b3fe7..213af00a 100644 --- a/router/cashu.py +++ b/router/cashu.py @@ -1,5 +1,4 @@ import os -import httpx import asyncio import time @@ -7,7 +6,6 @@ from sixty_nuts import Wallet from sqlmodel import select, func, col from .db import ApiKey, AsyncSession, get_session -from .db import ApiKey, AsyncSession RECEIVE_LN_ADDRESS = os.environ["RECEIVE_LN_ADDRESS"] MINT = os.environ.get("MINT", "https://mint.minibits.cash/Bitcoin") diff --git a/router/discovery.py b/router/discovery.py index 5ca643e0..0ef3279a 100644 --- a/router/discovery.py +++ b/router/discovery.py @@ -49,7 +49,7 @@ async def query_nostr_relay_with_search( "limit": limit, "#p": [npub], # Posts that tag this pubkey } - except: + except Exception: # If conversion fails, try regular search filter_obj = { "kinds": kinds, diff --git a/router/proxy.py b/router/proxy.py index 0f358d61..0b7422c9 100644 --- a/router/proxy.py +++ b/router/proxy.py @@ -149,7 +149,6 @@ async def proxy( async def stream_with_cost(): # Store all chunks to analyze stored_chunks = [] - usage_data_found = False async for chunk in response.aiter_bytes(): # Store chunk for later analysis @@ -190,7 +189,6 @@ async def proxy( # Format as SSE and yield cost_json = json.dumps({"cost": cost_data}) yield f"data: {cost_json}\n\n".encode() - usage_data_found = True break except json.JSONDecodeError: continue diff --git a/tests/conftest.py b/tests/conftest.py index 723d35d4..14ced46f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,7 +57,6 @@ with patch("sixty_nuts.Wallet") as mock_wallet_class: from router.main import app from router.db import get_session - from router.models import MODELS @pytest.fixture(scope="session") diff --git a/tests/test_account.py b/tests/test_account.py index 14751804..4cdcfe8f 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -2,7 +2,7 @@ import pytest import pytest_asyncio import hashlib import uuid -from unittest.mock import patch, AsyncMock, MagicMock +from unittest.mock import patch, AsyncMock from httpx import AsyncClient from router.db import ApiKey, AsyncSession @@ -184,7 +184,6 @@ async def test_account_with_cashu_token( ): """Test authentication with a cashu token creates a new account.""" cashu_token = "cashuBqQSEQ123456" - hashed = hash_api_key(cashu_token) async def mock_credit_balance( token: str, key: ApiKey, session: AsyncSession @@ -200,7 +199,7 @@ async def test_account_with_cashu_token( "router.cashu.credit_balance", new_callable=AsyncMock, side_effect=mock_credit_balance, - ) as mock_credit: + ): response = await async_client.get( "/v1/wallet/", headers={"Authorization": f"Bearer {cashu_token}"} ) diff --git a/tests/test_models.py b/tests/test_models.py index c4a8494e..3bc74dcc 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,6 +1,6 @@ import pytest import asyncio -from unittest.mock import patch, AsyncMock, MagicMock +from unittest.mock import patch, AsyncMock from router.models import Model, Architecture, Pricing, TopProvider, update_sats_pricing, MODELS diff --git a/tests/test_proxy.py b/tests/test_proxy.py index c8301299..06f83d30 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -4,7 +4,7 @@ import json import os import uuid from unittest.mock import AsyncMock, patch -from httpx import AsyncClient, Response as HttpxResponse +from httpx import AsyncClient from router.db import ApiKey, AsyncSession