devopshq / artifactory

dohq-artifactory: a Python client for Artifactory
https://devopshq.github.io/artifactory/
MIT License
269 stars 137 forks source link

ArtifactoryPath.glob() failing on Python versions >= 3.11.4 #432

Open BradyBuchanan opened 9 months ago

BradyBuchanan commented 9 months ago

Recently, upon upgrading some machines to use Python 3.11.4, a script I use for cleaning up artifacts has stopped working, throwing the following error:

File "C:\ci-scripts\cleanup.py", line 117, in clean_up for p in repo_path.glob("**/*.zip"): File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 953, in glob for p in selector.select_from(self): File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 407, in _select_from for starting_point in self._iterate_directories(parent_path, is_dir, scandir): File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 391, in _iterate_directories entry_is_dir = entry.is_dir(follow_symlinks=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This seems to affect versions 3.11.4 and higher of Python, since this same script worked fine testing it with 3.11.0 up to 3.11.3.

allburov commented 9 months ago

Hi! Do you use 0.9.1 version?

BradyBuchanan commented 9 months ago

Hi, sorry I should have put that in the original ticket, yes I'm on version 0.9.1

hagenw commented 9 months ago

I can confirm this error using Python 3.11.5:

When doing

paths = [str(x) for x in path.glob("**/*") if x.is_file()]

I get

...
    def _iterate_directories(self, parent_path, is_dir, scandir):
        yield parent_path
        try:
            with scandir(parent_path) as scandir_it:
                entries = list(scandir_it)
            for entry in entries:
                entry_is_dir = False
                try:
>                   entry_is_dir = entry.is_dir(follow_symlinks=False)
E                   TypeError: ArtifactoryPath.is_dir() got an unexpected keyword argument 'follow_symlinks'
...
barneygale commented 9 months ago

It should be possible to fix this by adding a keyword-only follow_symlinks argument to ArtifactoryPath.is_dir(), which would bring it in line with os.DirEntry.is_dir(). See also https://github.com/python/cpython/pull/105794

RPCMoritz commented 4 months ago

As the PR was merged a couple of days ago, will there be a maintenance release with this fix available this week?

allburov commented 4 months ago

Done! https://github.com/devopshq/artifactory/releases/tag/0.10.0

hagenw commented 4 months ago

Unfortunately, publishing it on PyPI has failed: https://github.com/devopshq/artifactory/actions/runs/7882501690/job/21507817334

JnyJny commented 4 months ago

Another report of this bug using Python 3.11.4 and hopeful that the publishing error will be corrected soon!

zhan9san commented 4 months ago

IIUC, once #426 is merged, the publish action issue would be gone.

allburov commented 4 months ago

Released! https://pypi.org/project/dohq-artifactory/0.10.0/ Thank you all for the help, I feel the power of Open Source projects :heart:

Could you send a small feedback - did the fix help to solve the issue for all of your cases?

hagenw commented 1 month ago

Thanks for the fix, I can confirm that it is now working for Python 3.11.