-
Notifications
You must be signed in to change notification settings - Fork 63
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
v0.9.4 breaks the returns.json decorator with type=int #215
Comments
I see the same thing. Didn’t realize that this used to work. |
I have PR #229 prepped to fix this issue. |
…229) Fix ``@returns.json`` to cast JSON response (or field referenced by the ``key`` argument) using the ``type`` argument when the given type is callable. This restores behavior that was inadvertently changed in v0.9.3. Example: ```python @uplink.returns.from_json(key=("data", 0, "size"), type=int) @uplink.get("/users/{user}/repos") def get_first_repo_size(self, user): pass ``` ```python assert github.get_first_repo_size("prkumar") == 300 ``` #215
I've merged #229, so this should be fixed in the next minor release. I'm planning to conduct a release for v0.9.6 sometime in the next week. |
Here's the tentative CHANGELOG entry:
Let me know if anyone has any thoughts on the entry's clarity. I'm hoping the above message conveys the change's impact succinctly. |
This issue should be fixed in v0.9.6 |
This is also happening for |
@leiserfg - Can you provide a code sample to help reproduce? Also, could you explain the expected and actual behaviors you are seeing with Thanks! |
I was using it to automatically add the prefix to the token as from certain endpoint I was getting it without it (the "Bearer " part). Maybe I was abusing the API but it worked fine until that change. |
@leiserfg - Got it. If I understand correctly, you were using
|
Before
v0.9.4
this code worked and converted the JSON field to anint
:With
v0.9.4
the endpoint returns a<Response [200]>
object instead of the expectedint
.Am I not using the
type
argument ofreturns.json
as intended? It would be very useful to be able to do simple type conversions such as this without having to write a model.The text was updated successfully, but these errors were encountered: