Skip to content

Commit

Permalink
Reformat with ruff 0.8.3
Browse files Browse the repository at this point in the history
This includes new linting rules for FastAPI path operations. The
redundant declarations for response models are removed and the Query
parameters are declared with Annotated.
  • Loading branch information
jonathansick committed Jan 6, 2025
1 parent e016599 commit 13a1a2a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
1 change: 1 addition & 0 deletions changelog.d/20250106_122656_jsick_DM_48302.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
### Other changes

- Update `make update` to use the `--universal` flag for `uv pip compile`.
- Use `Annotated` for `Query` dependencies in the path operations.
2 changes: 1 addition & 1 deletion src/noteburst/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from safir.slack.blockkit import SlackException, SlackMessage, SlackTextField

__all__ = [
"TaskError",
"NbexecTaskError",
"NbexecTaskTimeoutError",
"NoteburstClientRequestError",
"NoteburstError",
"TaskError",
]


Expand Down
3 changes: 1 addition & 2 deletions src/noteburst/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from noteburst.config import config

__all__ = ["get_index", "external_router"]
__all__ = ["external_router", "get_index"]

external_router = APIRouter()
"""FastAPI router for all external handlers."""
Expand All @@ -26,7 +26,6 @@ class Index(BaseModel):
@external_router.get(
"/",
description=("Discover metadata about the application."),
response_model=Index,
response_model_exclude_none=True,
summary="Application metadata",
)
Expand Down
1 change: 0 additions & 1 deletion src/noteburst/handlers/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
" a health check. This route is not exposed outside the cluster and"
" therefore cannot be used by external clients."
),
response_model=Metadata,
response_model_exclude_none=True,
summary="Internal application metadata",
)
Expand Down
35 changes: 19 additions & 16 deletions src/noteburst/handlers/v1/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"/notebooks/",
summary="Submit a notebook for execution",
status_code=202,
response_model=NotebookResponse,
response_model_exclude_none=True,
)
async def post_nbexec(
Expand Down Expand Up @@ -81,30 +80,34 @@ async def post_nbexec(
@v1_router.get(
"/notebooks/{job_id}",
summary="Get information about a notebook execution job",
response_model=NotebookResponse,
response_model_exclude_none=True,
responses={404: {"description": "Not found", "model": ErrorModel}},
)
async def get_nbexec_job(
*,
job_id: str,
request: Request,
source: bool = Query(
False,
title="Include source ipynb",
description=(
"If set to true, the `source` field will include the JSON-encoded "
"content of the source ipynb notebook."
source: Annotated[
bool,
Query(
title="Include source ipynb",
description=(
"If set to true, the `source` field will include the "
"JSON-encoded content of the source ipynb notebook."
),
),
),
result: bool = Query(
True,
title="Include the result",
description=(
"If set to true and the notebook run is complete, the response "
"includes the executed notebook and metadata about the run."
] = False,
result: Annotated[
bool,
Query(
title="Include the result",
description=(
"If set to true and the notebook run is complete, the "
"response includes the executed notebook and metadata about "
"the run."
),
),
),
] = True,
logger: Annotated[structlog.BoundLogger, Depends(auth_logger_dependency)],
user: Annotated[str, Depends(auth_dependency)],
arq_queue: Annotated[ArqQueue, Depends(arq_dependency)],
Expand Down
2 changes: 1 addition & 1 deletion src/noteburst/user/_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from noteburst.config import config

__all__ = ["User", "AuthenticatedUser"]
__all__ = ["AuthenticatedUser", "User"]


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/noteburst/worker/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["ping", "nbexec", "run_python", "keep_alive"]
__all__ = ["keep_alive", "nbexec", "ping", "run_python"]

from .keepalive import keep_alive
from .nbexec import nbexec
Expand Down

0 comments on commit 13a1a2a

Please sign in to comment.