You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When decorating a consumer method with @returns and also including a return annotation, it seems that the return annotation is considered the converter type instead of the type given in the @returns decorator.
To Reproduce
Here's an example that reproduces the issue:
fromcollectionsimportnamedtuplefrommarshmallowimportSchema, fields, post_loadfromtypingimportListfromuplinkimportget, post, json, retry, returns, Consumer, Path, Query, BodyRepo=namedtuple("Repo", field_names=["owner", "name"])
classRepoResource(Schema):
"""Schema for GitHub's repository resource."""full_name=fields.Str()
@post_loaddefmake_repo(self, data):
"""Decodes the repository resource into a Python object."""returnRepo(*data["full_name"].split("/"))
classGitHub(Consumer):
"""A Python Client for the GitHub API"""@retry(max_attempts=3)@returns.json(List[RepoResource])@get("/users/{user}/repos", args={"user": Path, "sort_by": Query("sort")})defget_repos(self, user: str, sort_by: str="created") ->List[Repo]:
"""Get user's public repositories"""@json@returns.json(RepoResource)@post("/user/repos", args={"repo": Body(RepoResource), "access_token": Query})defcreate_repo(self, repo: Repo, access_token: str) ->Repo:
"""Create a repository for the authenticated user."""if__name__=="__main__":
github=GitHub(base_url="https://api.github.com/")
print(github.get_repos("prkumar"))
Expected behavior
The expected behavior here is to
Additional context
It seems that annotating the consumer class with @returns.* also is effected, as expected. We need to make sure that the use case of @returns as the class decorator is also supported.
The text was updated successfully, but these errors were encountered:
Describe the bug
When decorating a consumer method with
@returns
and also including a return annotation, it seems that the return annotation is considered the converter type instead of the type given in the@returns
decorator.To Reproduce
Here's an example that reproduces the issue:
Expected behavior
The expected behavior here is to
Additional context
It seems that annotating the consumer class with
@returns.*
also is effected, as expected. We need to make sure that the use case of@returns
as the class decorator is also supported.The text was updated successfully, but these errors were encountered: