starlette icon indicating copy to clipboard operation
starlette copied to clipboard

Add `ContentType` generic to `Response`

Open Kludex opened this issue 1 year ago • 1 comments

  • Retry of https://github.com/encode/starlette/pull/1534.

At the time that PR was implemented the default= parameter was not available on TypeVar, and mypy didn't support it.

Now it's possible to achieve what that PR intended.

Kludex avatar Mar 19 '24 21:03 Kludex

I think JsonResponse and others don’t actually accept Any, they accept a limited set of types. Is that codified in this PR? If it is I’m missing it.

You are right, but I'm not changing that in this PR. And I think there was an attempt to change the type, but it failed, and we had to revert.

Kludex avatar Mar 21 '24 12:03 Kludex