Replies: 1 comment 5 replies
-
Check #2218. We're trying... |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there!
I was playing around with
request.state
, and I was wondering if we could make it generic, so that users can get better autocomplete on it (and maybe a bit of type safety too).The way this would work is where you accept a
Request
you could also doRequest[MyStateType]
, andrequest.state
would be of typeMyStateType
I think we can implement this in a backwards compatible way if we use
TypeVar
from typing extensions with a default value of any, like this:This means that any current code wouldn't throw an error, and power users could type the state var 😊
The only issue I see at the moment is that
State
is a wrapper on a dict, but doesn't providegetitem
, and my assumption is that types for State would beTypedDicts
😊 but is should be easy to add support for that. But I'm also saying this without knowing the reason why the state is a class on top of a dict, so I might be wrong :DBeta Was this translation helpful? Give feedback.
All reactions