Does _StreamingResponse correctly inherit Response #2731
Unanswered
whymatter
asked this question in
Potential Issue
Replies: 2 comments
-
You're right that something is wrong with our response inheritance chain. I think we should just re-design it, before 1.0. @abersheeran has thought about this before and has a proposed solution. I would be keep to accept a PR with the fix, ideally one that does the right thing but still tries to minimize breaking changes. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If you're interested, I have a code here that I think is a good inheritance of Response class. https://github.com/abersheeran/baize/blob/master/baize/asgi/responses.py |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I came across this discussion since we were affected by this change. While I understand that we can not expect a
StreamingResponse
I have another issue.Disclaimer: Since I am not a 100% Python typing expert please correct me if I am wrong but my understanding is that a derived class should have all attributed that the base class publishes.
The
_StreamingResponse
inheritsResponse
but does not call the super constructur, hence_StreamingResponse
does not have the attributes thatResponse
promises (e.g.body
). Imho there are three possible solutions:_body
. This hides it from external use (I dont think that is the way to go)body
to_StreamingResponse
e.g. by callingsuper
body
from Response or extract another base class likeBaseResponse
that does not have bodyBeta Was this translation helpful? Give feedback.
All reactions