Skip to content

Commit ec64a43

Browse files
Python 3.14 compatibility
Between Python 3.13 and Python 3.14: - glob._Globber was renamed to glob._GlobberBase - Support for passing keyword arguments to pathlib.Path has been removed Guard changes with Python 3.14 version check.
1 parent e0d30c3 commit ec64a43

5 files changed

Lines changed: 23 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
17+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
1818

1919
steps:
2020
- uses: actions/checkout@v4

artifactory.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from dohq_artifactory.compat import IS_PYTHON_3_10_OR_NEWER
5858
from dohq_artifactory.compat import IS_PYTHON_3_12_OR_NEWER
5959
from dohq_artifactory.compat import IS_PYTHON_3_13_OR_NEWER
60+
from dohq_artifactory.compat import IS_PYTHON_3_14_OR_NEWER
6061
from dohq_artifactory.exception import ArtifactoryException
6162
from dohq_artifactory.exception import raise_for_status
6263
from dohq_artifactory.logger import logger
@@ -1499,28 +1500,28 @@ class ArtifactoryOpensourceAccessor(_ArtifactoryAccessor):
14991500

15001501

15011502
# In Python 3.13, pathlib now reuses code from the glob package in order to implement
1502-
# the Path.glob() method. There are two related classes in the glob package, _Globber
1503+
# the Path.glob() method. There are two related classes in the glob package, _GlobberBase
15031504
# and _StringGlobber, where the former will delegate operations to the Path object while
15041505
# the latter directly calls os.path functions, performing actual file system calls. The
15051506
# private abstract base class of PurePath, PurePathBase, sets the _globber class
1506-
# attribute to _Globber, while PurePath overrides it to be _StringGlobber.
1507+
# attribute to _GlobberBase, while PurePath overrides it to be _StringGlobber.
15071508
#
1508-
# We create a custom subclass that explicitly subclasses _Globber and not
1509+
# We create a custom subclass that explicitly subclasses _GlobberBase and not
15091510
# _StringGlobber, since we want the version that delegates file system operations to the
15101511
# Path objects.
15111512
#
1512-
# In addition, we override _Globber.recursive_selector() with a copy of the original
1513+
# In addition, we override _GlobberBase.recursive_selector() with a copy of the original
15131514
# code but with one modification. Inside the definition of the nested select_recursive()
15141515
# function, we # add 1 to the original value of match_pos. The reason for this is that
15151516
# the add_slash() method will not actually add a slash when the path object is an
15161517
# instance of a Path subclass, since it will normally get normalized away. The match
15171518
# position therefore needs to be incremented by 1 in order to account for the actual
15181519
# slash character that appears when inspecting children of the current directory. This
1519-
# isn't an issue in the actual use of _Globber in Python, since it converts all paths to
1520+
# isn't an issue in the actual use of _GlobberBase in Python, since it converts all paths to
15201521
# strings, and the add_slash() will literally append a slash character to the string
15211522
# path. See the original code in
1522-
# https://github.com/python/cpython/blob/v3.13.2/Lib/glob.py#L448-L510
1523-
class _ArtifactoryGlobber(glob._Globber if IS_PYTHON_3_13_OR_NEWER else object):
1523+
# https://github.com/python/cpython/blob/v3.14.0/Lib/glob.py#L445-L505
1524+
class _ArtifactoryGlobber(glob._GlobberBase if IS_PYTHON_3_14_OR_NEWER else glob._Globber if IS_PYTHON_3_13_OR_NEWER else object):
15241525
def recursive_selector(self, part, parts):
15251526
"""Returns a function that selects a given path and all its children,
15261527
recursively, filtering by pattern.
@@ -1713,7 +1714,12 @@ def __init__(self, *args, **kwargs):
17131714
if not IS_PYTHON_3_12_OR_NEWER:
17141715
return
17151716

1716-
super().__init__(*args, **kwargs)
1717+
# Supplying keyword arguments to pathlib.PurePath is deprecated
1718+
# since Python 3.12 and has been removed in Python 3.14
1719+
if IS_PYTHON_3_14_OR_NEWER:
1720+
super().__init__(*args)
1721+
else:
1722+
super().__init__(*args, **kwargs)
17171723

17181724
cfg_entry = get_global_config_entry(self.drive)
17191725

dohq_artifactory/compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
# parts of the code once python3.12 is no longer supported. This constant helps
1414
# identifying those.
1515
IS_PYTHON_3_13_OR_NEWER = sys.version_info >= (3, 13)
16+
# In Python 3.14:
17+
# glob._Globber was renamed to glob._GlobberBase:
18+
# https://github.com/python/cpython/commit/242c7498e5a889b47847fb6f0f133ce461fa7e24
19+
# Support for passing keyword arguments to pathlib.Path has been removed:
20+
# https://github.com/python/cpython/commit/7d8725ac6f3304677d71dabdb7c184e98a62d864
21+
IS_PYTHON_3_14_OR_NEWER = sys.version_info >= (3, 14)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"Programming Language :: Python :: 3.11",
4949
"Programming Language :: Python :: 3.12",
5050
"Programming Language :: Python :: 3.13",
51+
"Programming Language :: Python :: 3.14",
5152
"Topic :: Software Development :: Libraries",
5253
"Topic :: System :: Filesystems",
5354
],

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ envlist =
66
py311
77
py312
88
py313
9+
py314
910
pre-commit
1011

1112
[testenv]

0 commit comments

Comments
 (0)