Open
Description
I have some code that uses resolves, I get the following warning:
831aC:\Python3126\Lib\pathlib.py:1250: RuntimeWarning: coroutine 'AsyncPath.stat' was never awaited
p.stat()
Object allocated at (most recent call last):
File "C:\Python3126\Lib\pathlib.py", lineno 1250
p.stat()
I believe this is caused by, although resolve is awaited, the implementation of resolve uses await to_thread on super().resolve.
The pathlib implementaiton of resolve then does p.stat, which because p (which in the resolve method is generated from self and so) is an AsyncPath. This stat then returns a coroutine, rather than being a simple method as in the default Path implementation.
As a workaround resolve can be passed strict=True which skips the stat check. (This does indeed supress the warning)
A quick fix would probably be to have the AsyncPath resolve method pass a reconstructed Path to the called resolve method, rather than self.
Metadata
Metadata
Assignees
Labels
No labels