We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Annotating consumer class with @returns.* decorator doesn't propagate in some cases to consumer methods.
@returns.*
To Reproduce
from collections import namedtuple from marshmallow import Schema, fields, post_load from typing import List from uplink import get, post, json, retry, returns, Consumer, Path, Query, Body Repo = namedtuple("Repo", field_names=["owner", "name"]) class RepoResource(Schema): """Schema for GitHub's repository resource.""" full_name = fields.Str() @post_load def make_repo(self, data): """Decodes the repository resource into a Python object.""" return Repo(*data["full_name"].split("/")) @returns.json class GitHub(Consumer): """A Python Client for the GitHub API""" @retry(max_attempts=3) @get("/users/{user}/repos", args={"user": Path, "sort_by": Query("sort")}) def get_repos(self, user: str, sort_by: str = "created") -> List[RepoResource]: """Get user's public repositories""" @json @post("/user/repos", args={"repo": Body(RepoResource), "access_token": Query}) def create_repo(self, repo: Repo, access_token: str) -> RepoResource: """Create a repository for the authenticated user.""" if __name__ == "__main__": github = GitHub(base_url="https://api.github.com/") print(github.get_repos("prkumar"))
The printed out response is a requests.Response object instead of the expected Repo object.
requests.Response
Repo
Expected behavior The expected behavior is that @returns.json propagates to consumer methods.
@returns.json
The text was updated successfully, but these errors were encountered:
Merge pull request #154 from prkumar/v0.9.0/fix-returns
472c28d
Refactor @returns.* decorator implementations (#144, #145)
No branches or pull requests
Describe the bug
Annotating consumer class with
@returns.*
decorator doesn't propagate in some cases to consumer methods.To Reproduce
The printed out response is a
requests.Response
object instead of the expectedRepo
object.Expected behavior
The expected behavior is that
@returns.json
propagates to consumer methods.The text was updated successfully, but these errors were encountered: