chore: reduce max complexity lint (#3230)

This commit is contained in:
dni ⚡
2025-07-02 13:02:47 +02:00
committed by GitHub
parent 5f0a8d78e0
commit 9b1418b1f4
10 changed files with 10 additions and 11 deletions

View File

@@ -277,7 +277,7 @@ async def check_installed_extensions(app: FastAPI):
logger.info(f"{ext.id} ({ext.installed_version})")
async def build_all_installed_extensions_list(
async def build_all_installed_extensions_list( # noqa: C901
include_deactivated: Optional[bool] = True,
) -> list[InstallableExtension]:
"""

View File

@@ -353,7 +353,7 @@ async def extensions_list():
help="Admin user ID (must have permissions to install extensions).",
)
@coro
async def extensions_update(
async def extensions_update( # noqa: C901
extension: Optional[str] = None,
all_extensions: Optional[bool] = False,
repo_index: Optional[str] = None,

View File

@@ -92,7 +92,7 @@ async def get_latest_payments_by_extension(
)
async def get_payments_paginated(
async def get_payments_paginated( # noqa: C901
*,
wallet_id: Optional[str] = None,
user_id: Optional[str] = None,

View File

@@ -93,7 +93,7 @@ async def api_create_account(data: CreateWallet) -> Wallet:
@api_router.get("/api/v1/lnurlscan/{code}")
async def api_lnurlscan(
async def api_lnurlscan( # noqa: C901
code: str, wallet: WalletTypeInfo = Depends(require_invoice_key)
):
try:

View File

@@ -658,7 +658,7 @@ def dict_to_submodel(model: type[TModel], value: dict | str) -> TModel | None:
return dict_to_model(_subdict, model)
def dict_to_model(_row: dict, model: type[TModel]) -> TModel:
def dict_to_model(_row: dict, model: type[TModel]) -> TModel: # noqa: C901
"""
Convert a dictionary with JSON-encoded nested models to a Pydantic model
:param _dict: Dictionary from database

View File

@@ -69,7 +69,7 @@ def render_html_error(request: Request, exc: Exception) -> Optional[Response]:
)
def register_exception_handlers(app: FastAPI):
def register_exception_handlers(app: FastAPI): # noqa: C901
"""Register exception handlers for the FastAPI app"""
@app.exception_handler(Exception)

View File

@@ -513,7 +513,7 @@ class NWCConnection:
if subscription: # Check if the subscription exists first
subscription["future"].set_exception(Exception(info))
async def _on_event_message(self, msg: list[Union[str, dict]]):
async def _on_event_message(self, msg: list[Union[str, dict]]): # noqa: C901
"""
Handles EVENT messages from the relay.
"""

View File

@@ -487,7 +487,7 @@ class StrikeWallet(Wallet):
return None
async def _get_payment_status_by_checking_id(
async def _get_payment_status_by_checking_id( # noqa: C901
self, checking_id: str
) -> PaymentStatus:
r_payment = await self._get(f"/payments/{checking_id}")

View File

@@ -211,8 +211,7 @@ classmethod-decorators = [
]
[tool.ruff.lint.mccabe]
# TODO: Decrease this to 10.
max-complexity = 16
max-complexity = 10
[tool.ruff.lint.flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.

View File

@@ -74,7 +74,7 @@ def sign_event(pub_key, priv_key, event):
return event
async def handle(wallet, mock_settings, data, websocket, path):
async def handle(wallet, mock_settings, data, websocket, path): # noqa: C901
async for message in websocket:
if not wallet:
continue