✨ Allow None as return type for bodiless responses#9425
✨ Allow None as return type for bodiless responses#9425tiangolo merged 5 commits intofastapi:masterfrom
None as return type for bodiless responses#9425Conversation
This comment was marked as outdated.
This comment was marked as outdated.
243f74a to
bb5ef4a
Compare
|
📝 Docs preview for commit bb5ef4a at: https://647f33cb7357732441e2ff02--fastapi.netlify.app |
|
I tested this using |
|
@csbasil I rebased after you approved it. Are there any plans on merging this PR? |
None as return type for bodiless responses
This comment was marked as outdated.
This comment was marked as outdated.
Yes, I thought it's not necessary to get the actual type in this case, since It might be a bit faster to compare the string further up in the stack, but that's probably negligible. There may be other arguments about using one over the other. |
None as return type for bodiless responsesNone as return type for bodiless responses
|
@tiangolo can we get this merged? it will fix this issue 🙏 |
5ef537b to
4bddd72
Compare
|
Rebased on top of current |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Thanks! ☕ I tweaked the implementation to not depend on a literal |
Fixes #9424
If the return annotation of the route function is exactly
"None", returnNonefor the typed annotation. This allows the status code204 No Contentto be used.