asgi.App should not be a sub-class of falcon.App #2210
davetapley
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
|
Hi, Please take a look at #2211 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't follow, you can surely create a type guard to accept only a subclass. What you can't do is the inverse, you can't create a type guard for the superclass |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is motivated by #2209 (comment), TLDR:
Because an
asgi.Appis (in the LSP sense) afalcon.App,any type for a
falcon.Appmust be 'polluted' with types which only make sense in the ASGI context. E.g.:The
simulate_requestmethods intesting.clientmust returnResult | StreamedResult,even though it's not possible to get a
StreamedResultwith WSGI (akafalcon.App).That's awkward because
StreamedResultdoesn't have the very usefultextandjsonmethods.I would like to propose moving the shared functionality out of
falcon.Appand in to a mix-in class.Then methods like ⬇️ could be extended with a
TypeGuard.falcon/falcon/testing/client.py
Line 2177 in 4910dd7
and it will be possible to use
@overloadto correctly narrow to justResult.I suspect there are other places in the code which would benefit from this (e.g. all the ASGI only websocket code).
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions