Tinche / aiofiles

File support for asyncio
Apache License 2.0
2.67k stars 149 forks source link

DeprecationWarning at aiofiles.os:8 #74

Closed HacKanCuBa closed 4 years ago

HacKanCuBa commented 4 years ago

Hi there! Pytest is correctly complaining about the use of @coroutine decorator at aiofiles.os line 8. This is for the current latest 0.5.0 version.

https://github.com/Tinche/aiofiles/blob/258e95640d6242c53a1c0d84e68343d79d80d781/aiofiles/os.py#L7-L16

The fix would be to use async def directly:

def wrap(func):
    @wraps(func)
    async def run(*args, loop=None, executor=None, **kwargs):
        if loop is None:
            loop = asyncio.get_event_loop()
        pfunc = partial(func, *args, **kwargs)
        return loop.run_in_executor(executor, pfunc)

    return run
Tinche commented 4 years ago

Agreed, could you create a quick PR?

gyermolenko commented 4 years ago

Agreed, could you create a quick PR?

related #54 (! please note that it also changes return type of the wrapped func)

HacKanCuBa commented 4 years ago

Agreed, could you create a quick PR?

Sure, give me 5' :)

HacKanCuBa commented 4 years ago

Done in #75

HacKanCuBa commented 4 years ago

Agreed, could you create a quick PR?

related #54 (! please note that it also changes return type of the wrapped func)

Woops, sorry I missed this. Both PRs clashes, so I guess we need to pick one.

HacKanCuBa commented 4 years ago

I saw that Travis failed in my PR so I checked out the project locally and saw that, at least for py3.8, tests are failing for what is mentioned in #54. With that patch all tests passed. So, all in all, I think we need to go for #54, which is more complete and fixes other issue, instead of my patch.

Tinche commented 4 years ago

Merged that one in! Can this issue now be closed?

HacKanCuBa commented 4 years ago

Sure do! I'm closing it. Thanks!