Skip to content
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 use_args/use_kwargs decorators with async def coroutines #170

Merged
merged 4 commits into from Jun 4, 2017

Conversation

@zaro
Copy link
Contributor

commented May 22, 2017

make the following work

@use_args({'name': fields.Str()})
async def api_test(request, args):
      ....

I am not certain this is the best way to achieve it, but testing it on my aiohttp application shows it works well.

if not req_obj:
req_obj = self.get_request_from_view_args(func, args, kwargs)
# NOTE: At this point, argmap may be a Schema, callable, or dict
parsed_args = await self.parse(argmap,

This comment has been minimized.

Copy link
@sloria

sloria May 31, 2017

Member

In order for builds to pass on python < 3.5, I think you'll need to add # flake8: noqa to this line.

@sloria
Copy link
Member

left a comment

Thanks for the PR! I would definitely like to support async def coroutines. I am lukewarm on this because of the repeated code, but I can't think of a better way to do it at the moment.

Once the build is passing, this should be good to merge.

@zaro

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2017

@sloria

This comment has been minimized.

Copy link
Member

commented Jun 1, 2017

I believe it's failing flake8 on py34 async/await is only valid syntax in py>=3.5. As suggessted in #170 (comment) , you can just tell flake8 to ignore that line.

@zaro

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2017

@sloria

This comment has been minimized.

Copy link
Member

commented Jun 1, 2017

Sounds like a good approach.

@zaro zaro force-pushed the zaro:dev branch from 4e42a2d to aa4100c Jun 2, 2017

@zaro

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2017

Seems I managed to find the right flake8 exclude list for all tests to pass :)

@sloria sloria referenced this pull request Jun 3, 2017
@sloria

This comment has been minimized.

Copy link
Member

commented Jun 3, 2017

Excellent. Thanks @zaro! I've added tests for this in #172 . Once those pass, this will be good to merge.

@sloria sloria merged commit aa4100c into marshmallow-code:dev Jun 4, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.