Giter Club home page Giter Club logo

Comments (5)

alexdelorenzo avatar alexdelorenzo commented on May 30, 2024

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.

alexdelorenzo avatar alexdelorenzo commented on May 30, 2024

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.

alexdelorenzo avatar alexdelorenzo commented on May 30, 2024

Here is a list of changes to the upstream pathlib package from the 3.10 alpha 7 stdlib:

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.

alexdelorenzo avatar alexdelorenzo commented on May 30, 2024

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:

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.

barneygale avatar barneygale commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.