Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support Python 3.12 #458

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def quote_url(url):
return quoted_url


class _ArtifactoryFlavour(pathlib._Flavour):
class _ArtifactoryFlavour:
"""
Implements Artifactory-specific pure path manipulations.
I.e. what is 'drive', 'root' and 'path' and how to split full path into
Expand All @@ -440,7 +440,6 @@ class _ArtifactoryFlavour(pathlib._Flavour):
sep = "/"
altsep = "/"
has_drv = True
pathmod = pathlib.posixpath
is_supported = True

def _get_base_url(self, url):
Expand Down Expand Up @@ -1501,10 +1500,16 @@ class ArtifactoryPath(pathlib.Path, PureArtifactoryPath):
# see changes in pathlib.Path, slots are no more applied
# https://github.com/python/cpython/blob/ce121fd8755d4db9511ce4aab39d0577165e118e/Lib/pathlib.py#L952
_accessor = _artifactory_accessor
parser = _ArtifactoryFlavour()
else:
# in 3.9 and below Pathlib limits what members can be present in 'Path' class
__slots__ = ("auth", "verify", "cert", "session", "timeout")


def __init__(self, *args, **kwargs):
# supplying keyword arguments to pathlib.PurePath is deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we should not silently suppress the kwargs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We should just axe this override, as you're passing via args below anyway.

return super().__init__(*args)

def __new__(cls, *args, **kwargs):
"""
pathlib.Path overrides __new__ in order to create objects
Expand All @@ -1514,6 +1519,10 @@ def __new__(cls, *args, **kwargs):
only then add auth information.
"""
obj = pathlib.Path.__new__(cls, *args, **kwargs)

if sys.version_info.major == 3 and sys.version_info.minor >= 12:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not have version specific behaviour if this can be avoided. If positional arguments can be passed in all supported earlier versions, then we should be doing it for all versions.

Why is __init__ only being called here for 3.12+?

# supplying keyword arguments to pathlib.PurePath is deprecated
obj.__init__(*args)

cfg_entry = get_global_config_entry(obj.drive)

Expand Down
Loading