Comments (5)
The specific error in this ticket is fixed in this branch: https://github.com/alexdelorenzo/aiopath/tree/Python-3.10
Versions 0.6.x
on PyPI work with Python 3.10a7: python3 -m install aiopath==0.6.1
from aiopath.
Using the latest branch of pytest (via https://github.com/pytest-dev/pytest) with 3.10 support, it appears that the coroutine method AsyncPath.resolve()
is broken.
______________________________________________________________________________ test_home ______________________________________________________________________________
@pytest.mark.asyncio
async def test_home():
home = Path.home()
ahome = await AsyncPath.home()
> await _test_is(home, ahome)
tests.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests.py:67: in _test_is
await _test_is(path.parent, apath.parent, test_parent=False)
tests.py:74: in _test_is
await apath.resolve(),
aiopath/path.py:491: in resolve
s: Optional[str] = await self._flavour.resolve(self, strict=strict)
aiopath/flavours.py:90: in resolve
result = await _resolve(base, str(path))
aiopath/flavours.py:73: in _resolve
target = await accessor.readlink(newpath)
../../../.pyenv/versions/3.10-dev/lib/python3.10/site-packages/aiofiles/os.py:13: in run
return await loop.run_in_executor(executor, pfunc)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = None
def run(self):
if not self.future.set_running_or_notify_cancel():
return
try:
> result = self.fn(*self.args, **self.kwargs)
E TypeError: readlink() takes exactly 1 positional argument (2 given)
../../../.pyenv/versions/3.10-dev/lib/python3.10/concurrent/futures/thread.py:52: TypeError
from aiopath.
Here is a list of changes to the upstream pathlib
package from the 3.10 alpha 7 stdlib:
- python/cpython#19220
- python/cpython#19481
- python/cpython#18838
- python/cpython#19342
- python/cpython#18864
- python/cpython#24294
- python/cpython#18834
- python/cpython#18841
- python/cpython#25240
Full list of changes here: https://github.com/python/cpython/commits/master/Lib/pathlib.py
These changes will need to be ported to aiopath
's Python-3.10
branch.
from aiopath.
Just some notes for myself:
I started this project as a fork of pathlib
for an opportunity to port synchronous code to asynchronous Python and to work with some standard library code. I wanted to keep the same class hierarchy and API to address use cases that might consume those interfaces, even if I personally don't plan on using them.
It might be worth profiling trio
's approach of just wrapping synchronous I/O pathlib
methods with decorators that submit the methods to a threadpool in the background: https://github.com/python-trio/trio/blob/6754c74eacfad9cc5c92d5c24727a2f3b620624e/trio/_path.py
That way I'm not beholden to upstream maintainers' changes in the stdlib, and as long as the API stays the same, aiopath
won't have to change much if at all between changes to the stdlib.
The downside is punting some CPU-bound code to the threadpool, which, all in all, probably has an insignificant overhead.
It can also introduce problems like these:
- https://github.com/python-trio/trio/issues?q=is%3Aissue+pathlib+is%3Aopen
- https://github.com/python-trio/trio/issues?q=is%3Aissue+pathlib+is%3Aclosed
However, Barney Gale's updates to pathlib
that appeared in 3.10 alpha 7 are stepping stones on a roadmap towards an extensible pathlib
: https://discuss.python.org/t/make-pathlib-extensible/3428/
In a world with an extensible pathlib
, it makes sense for aiopath
to have the current class hierarchy it has (with AsyncPath
subclassing AsyncPurePath
etc). I'd also assume in such a world, pathlib
would also have a stable interface to support consumers like aiopath
.
from aiopath.
I'm sorry my changes have broken things! As always with extending private APIs in the standard library, it can be a bit of a minefield. As you mentioned, I'm working towards a pathlib.AbstractPath
class which supports subclassing. I'm hoping this can land in Python 3.11, all being well :)
from aiopath.
Related Issues (20)
- .read() doesn't advance offset HOT 4
- Put a lock on IterableAIOFile's read/write methods HOT 2
- Please don't lock package requirements to specific versions HOT 3
- Looks like 0.5.7 has broken things HOT 5
- Please include requirements.txt in PyPi source distribution HOT 3
- aiofile backend
- Import Fails on Python 3.7.0
- Windows readlink() Behavior Differences
- Consider Using a Different License
- use buffer
- ImportError: cannot import name '_NormalAccessor' from 'pathlib' (Python 3.11)
- License HOT 2
- Conda package
- Support older python versions
- How does this project relate to anyio.Path?
- Package has type annotations but mypy won't use them HOT 2
- TypeError: PurePath._from_parts() got an unexpected keyword argument 'init' HOT 2
- AsyncPath using synchronous Path.walk
- Drop anyio dependency
- rglob is broken on python 3.12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiopath.