Skip to content

Commit a733520

Browse files
committed
fix: resolve MyPy type checking and pre-commit issues - Add proper type annotations for all functions - Fix Sequence to list conversion for SQLModel results - Add FastAPI import for proper typing - Fix end-of-file and formatting issues
1 parent 3bd6b8a commit a733520

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

backend/app/api/routes/analytics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ class ItemAnalyticsTrends(pydantic.BaseModel):
5252
@router.get("/user-summary", response_model=UserAnalyticsSummary)
5353
def get_user_summary(
5454
session: SessionDep,
55+
) -> (
56+
UserAnalyticsSummary
5557
): # get_current_active_superuser is imported but not used here yet
5658
with tracer.start_as_current_span("user_summary_endpoint"):
57-
users_list: list[User]
5859
with tracer.start_as_current_span("fetch_all_users_sql"):
5960
statement = select(User)
60-
users_list = session.exec(statement).all()
61+
users_list = list(session.exec(statement).all())
6162

6263
if not users_list:
6364
return UserAnalyticsSummary(
@@ -134,12 +135,11 @@ def get_user_summary(
134135

135136

136137
@router.get("/item-trends", response_model=ItemAnalyticsTrends)
137-
def get_item_trends(session: SessionDep):
138+
def get_item_trends(session: SessionDep) -> ItemAnalyticsTrends:
138139
with tracer.start_as_current_span("item_trends_endpoint"):
139-
items_list: list[Item]
140140
with tracer.start_as_current_span("fetch_all_items_sql"):
141141
statement = select(Item)
142-
items_list = session.exec(statement).all()
142+
items_list = list(session.exec(statement).all())
143143

144144
if not items_list:
145145
return ItemAnalyticsTrends(

backend/app/core/telemetry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
from fastapi import FastAPI
34
from opentelemetry import trace
45
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
56
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
@@ -12,7 +13,7 @@
1213
from app.core.db import engine # Assuming engine is in app.core.db
1314

1415

15-
def init_telemetry(app):
16+
def init_telemetry(app: FastAPI) -> None:
1617
# Set service name, try from settings or default
1718
service_name = getattr(settings, "OTEL_SERVICE_NAME", "fastapi-application")
1819

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dev-dependencies = [
3535
"pytest<8.0.0,>=7.4.3",
3636
"mypy<2.0.0,>=1.8.0",
3737
"ruff<1.0.0,>=0.2.2",
38-
"pre-commit<4.0.0,>=3.6.2",
38+
"pre-commit>=3.6.2,<4.0.0",
3939
"types-passlib<2.0.0.0,>=1.7.7.20240106",
4040
"coverage<8.0.0,>=7.4.3",
4141
]

development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,4 @@ Adminer: http://localhost.tiangolo.com:8080
204204

205205
Traefik UI: http://localhost.tiangolo.com:8090
206206

207-
MailCatcher: http://localhost.tiangolo.com:1080
207+
MailCatcher: http://localhost.tiangolo.com:1080

frontend/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ openapi.json
2727
/playwright-report/
2828
/blob-report/
2929
/playwright/.cache/
30-
/playwright/.auth/
30+
/playwright/.auth/

0 commit comments

Comments
 (0)