-
-
Notifications
You must be signed in to change notification settings - Fork 511
Closed
Labels
bugSomething isn't workingSomething isn't workingregressionBehavior has changed for worse with a releaseBehavior has changed for worse with a releasestubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)
Description
Bug report
Example code:
@admin.action(description="get some JSON")
def get_json(
self,
request: HttpRequest,
queryset: QuerySet[SomeModel],
) -> HttpResponse:
return HttpResponse(
json.dumps({"some": "json"}),
"application/json",
status.HTTP_200_OK,
)
What's wrong
In older versions of django-stubs, this code was fine, because @admin.action
was typed as:
def action(
function: Callable[[ModelAdmin, HttpRequest, QuerySet], None] | None = ...,
*,
permissions: Sequence[str] | None = ...,
description: str | None = ...,
) -> Callable: ...
But in #1267, this was changed to hard-code the return value as None
.
How is that should be
I'm not 100% sure what return values Django allows, but I think this should at least allow HTTP responses.
System information
- OS: Linux
python
version: 3.10.8django
version: 4.0.8mypy
version: 0.982django-stubs
version: 1.13.2django-stubs-ext
version: 0.7.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingregressionBehavior has changed for worse with a releaseBehavior has changed for worse with a releasestubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)