Skip to content

Commit d3a5582

Browse files
authored
refactor(web): migrate controllers to explicit FromPath markers (#107)
Migrate controllers.py route handlers from inferred/implicit path parameters to explicit FromPath type annotations to address Litestar deprecation warnings.
1 parent ae058a3 commit d3a5582

7 files changed

Lines changed: 1656 additions & 1018 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,11 @@ CLAUDE.md
171171
GEMINI.md
172172
# Flow specification files (local-only)
173173
.agent/
174+
.agents/
174175
.geminiignore
176+
177+
# Beads / Dolt files (added by bd init)
178+
.dolt/
179+
*.db
180+
.beads-credential-key
181+
opencode.json

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: mixed-line-ending
1818
- id: trailing-whitespace
1919
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: "v0.15.4"
20+
rev: "v0.15.15"
2121
hooks:
2222
# Run the linter.
2323
- id: ruff
@@ -27,7 +27,7 @@ repos:
2727
- id: ruff-format
2828
types_or: [ python, pyi ]
2929
- repo: https://github.com/codespell-project/codespell
30-
rev: v2.4.1
30+
rev: v2.4.2
3131
hooks:
3232
- id: codespell
3333
exclude: "uv.lock|package.json|package-lock.json"

litestar_saq/__metadata__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Metadata for the Project."""
2+
# pyright: reportUnknownVariableType=false
23

34
from __future__ import annotations
45

litestar_saq/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,6 @@ def _has_otel_plugin(app: "Litestar") -> bool:
519519
OpenTelemetryPlugin, # pyright: ignore[reportAttributeAccessIssue,reportMissingImports,reportUnknownVariableType]
520520
)
521521

522-
return app.plugins.get(OpenTelemetryPlugin) is not None # pyright: ignore[reportUnknownArgumentType]
522+
return bool(app.plugins.get(OpenTelemetryPlugin))
523523
except ImportError:
524524
return False

litestar_saq/controllers.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import TYPE_CHECKING, Any, Optional, cast
44

55
from litestar.exceptions import NotFoundException
6+
from litestar.params import FromPath
67

78
if TYPE_CHECKING:
89
from litestar import Controller
@@ -131,7 +132,7 @@ async def queue_list(self, task_queues: "TaskQueues") -> "dict[str, list[QueueIn
131132
summary="Queue Detail",
132133
description="List queue details.",
133134
)
134-
async def queue_detail(self, task_queues: "TaskQueues", queue_id: str) -> "dict[str, QueueInfo]":
135+
async def queue_detail(self, task_queues: "TaskQueues", queue_id: FromPath[str]) -> "dict[str, QueueInfo]":
135136
"""Get queue information.
136137
137138
Args:
@@ -157,7 +158,7 @@ async def queue_detail(self, task_queues: "TaskQueues", queue_id: str) -> "dict[
157158
description="List job details.",
158159
)
159160
async def job_detail(
160-
self, task_queues: "TaskQueues", queue_id: str, job_id: str
161+
self, task_queues: "TaskQueues", queue_id: FromPath[str], job_id: FromPath[str]
161162
) -> "dict[str, dict[str, Any]]":
162163
"""Get job information.
163164
@@ -191,7 +192,9 @@ async def job_detail(
191192
description="Retry a failed job..",
192193
status_code=HTTP_202_ACCEPTED,
193194
)
194-
async def job_retry(self, task_queues: "TaskQueues", queue_id: str, job_id: str) -> "dict[str, str]":
195+
async def job_retry(
196+
self, task_queues: "TaskQueues", queue_id: FromPath[str], job_id: FromPath[str]
197+
) -> "dict[str, str]":
195198
"""Retry job.
196199
197200
Args:
@@ -217,7 +220,9 @@ async def job_retry(self, task_queues: "TaskQueues", queue_id: str, job_id: str)
217220
description="Abort active job.",
218221
status_code=HTTP_202_ACCEPTED,
219222
)
220-
async def job_abort(self, task_queues: "TaskQueues", queue_id: str, job_id: str) -> "dict[str, str]":
223+
async def job_abort(
224+
self, task_queues: "TaskQueues", queue_id: FromPath[str], job_id: FromPath[str]
225+
) -> "dict[str, str]":
221226
"""Abort job.
222227
223228
Args:
@@ -280,8 +285,8 @@ async def health(self, task_queues: "TaskQueues") -> Response[str]:
280285
)
281286
async def index(
282287
self,
283-
queue_id: Optional[str] = None,
284-
job_id: Optional[str] = None,
288+
queue_id: FromPath[Optional[str]] = None,
289+
job_id: FromPath[Optional[str]] = None,
285290
) -> str:
286291
return html_template
287292

litestar_saq/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def get_queues(self) -> "TaskQueues":
169169
def get_queue(self, name: str) -> "Queue":
170170
return self.get_queues().get(name)
171171

172-
@contextmanager
172+
@contextmanager # pyright: ignore[reportDeprecated]
173173
def server_lifespan(self, app: "Litestar") -> "Iterator[None]":
174174
import multiprocessing
175175
import platform

0 commit comments

Comments
 (0)