chore: reduce max complexity lint (#3230)
This commit is contained in:
parent
5765ea0276
commit
ba0f7a01ef
10 changed files with 10 additions and 11 deletions
|
|
@ -277,7 +277,7 @@ async def check_installed_extensions(app: FastAPI):
|
||||||
logger.info(f"{ext.id} ({ext.installed_version})")
|
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,
|
include_deactivated: Optional[bool] = True,
|
||||||
) -> list[InstallableExtension]:
|
) -> list[InstallableExtension]:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ async def extensions_list():
|
||||||
help="Admin user ID (must have permissions to install extensions).",
|
help="Admin user ID (must have permissions to install extensions).",
|
||||||
)
|
)
|
||||||
@coro
|
@coro
|
||||||
async def extensions_update(
|
async def extensions_update( # noqa: C901
|
||||||
extension: Optional[str] = None,
|
extension: Optional[str] = None,
|
||||||
all_extensions: Optional[bool] = False,
|
all_extensions: Optional[bool] = False,
|
||||||
repo_index: Optional[str] = None,
|
repo_index: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
wallet_id: Optional[str] = None,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ async def api_create_account(data: CreateWallet) -> Wallet:
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("/api/v1/lnurlscan/{code}")
|
@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)
|
code: str, wallet: WalletTypeInfo = Depends(require_invoice_key)
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -658,7 +658,7 @@ def dict_to_submodel(model: type[TModel], value: dict | str) -> TModel | None:
|
||||||
return dict_to_model(_subdict, model)
|
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
|
Convert a dictionary with JSON-encoded nested models to a Pydantic model
|
||||||
:param _dict: Dictionary from database
|
:param _dict: Dictionary from database
|
||||||
|
|
|
||||||
|
|
@ -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"""
|
"""Register exception handlers for the FastAPI app"""
|
||||||
|
|
||||||
@app.exception_handler(Exception)
|
@app.exception_handler(Exception)
|
||||||
|
|
|
||||||
|
|
@ -513,7 +513,7 @@ class NWCConnection:
|
||||||
if subscription: # Check if the subscription exists first
|
if subscription: # Check if the subscription exists first
|
||||||
subscription["future"].set_exception(Exception(info))
|
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.
|
Handles EVENT messages from the relay.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ class StrikeWallet(Wallet):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def _get_payment_status_by_checking_id(
|
async def _get_payment_status_by_checking_id( # noqa: C901
|
||||||
self, checking_id: str
|
self, checking_id: str
|
||||||
) -> PaymentStatus:
|
) -> PaymentStatus:
|
||||||
r_payment = await self._get(f"/payments/{checking_id}")
|
r_payment = await self._get(f"/payments/{checking_id}")
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,7 @@ classmethod-decorators = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.mccabe]
|
[tool.ruff.lint.mccabe]
|
||||||
# TODO: Decrease this to 10.
|
max-complexity = 10
|
||||||
max-complexity = 16
|
|
||||||
|
|
||||||
[tool.ruff.lint.flake8-bugbear]
|
[tool.ruff.lint.flake8-bugbear]
|
||||||
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
|
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ def sign_event(pub_key, priv_key, event):
|
||||||
return 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:
|
async for message in websocket:
|
||||||
if not wallet:
|
if not wallet:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue