Added Ruff linting
This commit is contained in:
1 parent
aa612103f4
commit
b3c16f78d6
4 files changed
+32
-3
No files matched your search
@@ -0,0 +1,28 @@
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
target-version = "py312"
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", "F", # pycodestyle errors, pyflakes (unused imports/variables, undefined names)
|
||||
"I", # import sorting (replaces isort)
|
||||
"B", # bugbear: likely bugs
|
||||
"ASYNC", # async mistakes
|
||||
"RUF006", # un-referenced asyncio.create_task (tasks can be garbage-collected)
|
||||
]
|
||||
ignore = ["E501"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["db_module", "metrics_server", "rabbitmq_handler", "secret_manager",
|
||||
"simple_logger_handler", "uvicorn_logger_config", "validator"]
|
||||
|
||||
[tool.ruff.format]
|
||||
indent-style = "tab"
|
||||
|
||||
[tool.ruff.lint.flake8-bugbear]
|
||||
extend-immutable-calls = [
|
||||
"fastapi.Depends",
|
||||
"fastapi.Query",
|
||||
"fastapi.Header",
|
||||
"fastapi.Body",
|
||||
"fastapi.Security",
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
ruff==0.17.0
|
||||
+2
-2
@@ -106,10 +106,10 @@ async def pull_notifications(
|
||||
)
|
||||
except (AMQPException, OSError) as e:
|
||||
logger.error(f"[FastAPI] RabbitMQ unavailable for user_id={user_id}: {e}")
|
||||
raise HTTPException(status_code=503, detail="Message broker unavailable")
|
||||
raise HTTPException(status_code=503, detail="Message broker unavailable") from e
|
||||
except RuntimeError as e:
|
||||
logger.error(f"[FastAPI] Consumer not ready: {e}")
|
||||
raise HTTPException(status_code=503, detail="Service not ready")
|
||||
raise HTTPException(status_code=503, detail="Service not ready") from e
|
||||
|
||||
logger.info(f"[FastAPI] Retrieved {len(messages)} message(s) for user_id={user_id}")
|
||||
return PullResponse(messages=messages, count=len(messages), has_more=len(messages) >= MAX_MESSAGES)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from fastapi import FastAPI, Response
|
||||
from prometheus_client import generate_latest, CONTENT_TYPE_LATEST, Counter
|
||||
from prometheus_client import CONTENT_TYPE_LATEST, Counter, generate_latest
|
||||
|
||||
metrics_api = FastAPI(title="Metrics Server", description="Prometheus metrics endpoint")
|
||||
|
||||
|
||||
Reference in new issue
Block a user