-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow context to be used like a dict. #54
Conversation
That's a good idea to use a safe BTW, the reason I used to create an opinionated
|
Great suggestions. Updated the PR. |
I got an idea, maybe it's simpler with just a line of def __setitem__(self, *args):
self.__setattr__(*args) This will naturally raise an |
Seems fine to me; tested it with a few different patterns and it didn't cause any issues. Updated! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
==========================================
- Coverage 92.34% 92.32% -0.03%
==========================================
Files 19 19
Lines 1869 1875 +6
==========================================
+ Hits 1726 1731 +5
- Misses 143 144 +1 ☔ View full report in Codecov by Sentry. |
Thanks! |
Nice one. |
* Add dict style access to context. * add test_servercontext --------- Co-authored-by: nggit <[email protected]>
* Add dict style access to context. * add test_servercontext --------- Co-authored-by: nggit <[email protected]>
Allows context to optionally be used like a dict.
Nice because it exposes safe
get()
and makes the context syntax less opinionated.Similar issue in Starlette: encode/starlette#2389