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
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.
The text was updated successfully, but these errors were encountered:
I have some code that uses resolves, I get the following warning:
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.
The text was updated successfully, but these errors were encountered: