-
Notifications
You must be signed in to change notification settings - Fork 28
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
warn if handle_request returns dict #449
Conversation
--HG-- branch : warn_dict_retval
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #449 +/- ##
==========================================
+ Coverage 71.74% 71.77% +0.02%
==========================================
Files 83 83
Lines 5713 5718 +5
Branches 1230 1231 +1
==========================================
+ Hits 4099 4104 +5
Misses 1336 1336
Partials 278 278
☔ View full report in Codecov by Sentry. |
@AvdN: Good idea! Should we use |
One thing that might be useful is keep a set of file-name, line-number tuples and only show the warning once for each combo. That set would have to be a |
I see. But if possible I would want to use the official mechanism. Maybe we should instead configure warnings on Lona startup to show at least all Lona related warnings |
You can define I am not sure if that is more of an official mechanism than using |
@sobolevn: Do you have an opinion on that? |
I created a question on stackoverflow with an extracted/abstracted version of this problem. Please have a look at that (and the answer). |
@AvdN: Nice! That would be a good solution I think |
Do you want me to make a new PR, or wait for comment from sobolevn? A new PR with the dependency on ruamel.std.warnings==0.2.2 (my preference), or the "standalone" solution (first part of the answer on SO)? Any preference for the name of the PendingDeprecrationWarning subclass? You can use PendingDeprecationWarning directly, but if you subclass it like
you can more easily use it in other places as well, and get an "auto deprecation" when you update the version (of course you still need to update the code to actually no longer handle the dict return). |
@AvdN: Feel free to start a PR. I would prefer a standalone solution. |
This change puts a warning in the logger if a call to handle_request returns a dict instead of response object.
The warning references the file and line number of the "offending" handle_request method and a link
to the Response Objects documentation.
The code could be changed to output the warning only once, but that might make the warning go unnoticed.