Skip to content

Commit 46728f6

Browse files
committed
Fix linter issues, move all IS_PYTHON_* to compat.py, explicit import
1 parent 27d86fe commit 46728f6

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

artifactory.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
from dohq_artifactory.admin import User
5252
from dohq_artifactory.auth import XJFrogArtApiAuth
5353
from dohq_artifactory.auth import XJFrogArtBearerAuth
54-
from dohq_artifactory.compat import * # noqa: this helper only contains version flags
54+
from dohq_artifactory.compat import IS_PYTHON_2
55+
from dohq_artifactory.compat import IS_PYTHON_3_10_OR_NEWER
56+
from dohq_artifactory.compat import IS_PYTHON_3_12_OR_NEWER
5557
from dohq_artifactory.exception import ArtifactoryException
5658
from dohq_artifactory.exception import raise_for_status
5759
from dohq_artifactory.logger import logger
@@ -73,11 +75,6 @@
7375
default_config_path = "~/.artifactory_python.cfg"
7476
global_config = None
7577

76-
# Pathlib.Path changed significantly in 3.12, so we will not need several
77-
# parts of the code once python3.11 is no longer supported. This constant helps
78-
# identifying those.
79-
_IS_PYTHON_3_12_OR_NEWER = sys.version_info >= (3, 12)
80-
8178

8279
def read_config(config_path=default_config_path):
8380
"""
@@ -429,7 +426,7 @@ def quote_url(url):
429426
return quoted_url
430427

431428

432-
class _ArtifactoryFlavour(object if _IS_PYTHON_3_12_OR_NEWER else pathlib._Flavour):
429+
class _ArtifactoryFlavour(object if IS_PYTHON_3_12_OR_NEWER else pathlib._Flavour):
433430
"""
434431
Implements Artifactory-specific pure path manipulations.
435432
I.e. what is 'drive', 'root' and 'path' and how to split full path into
@@ -1554,7 +1551,7 @@ def __new__(cls, *args, **kwargs):
15541551
"""
15551552

15561553
obj = pathlib.Path.__new__(cls, *args, **kwargs)
1557-
if _IS_PYTHON_3_12_OR_NEWER:
1554+
if IS_PYTHON_3_12_OR_NEWER:
15581555
# After python 3.12, all this logic can be moved to __init__
15591556
return obj
15601557

@@ -1611,7 +1608,7 @@ def _init(self, *args, **kwargs):
16111608
def __init__(self, *args, **kwargs):
16121609
# Up until python3.12, pathlib.Path was not designed to be initialized
16131610
# through __init__, so all that logic is in the __new__ method.
1614-
if not _IS_PYTHON_3_12_OR_NEWER:
1611+
if not IS_PYTHON_3_12_OR_NEWER:
16151612
return
16161613

16171614
super().__init__(*args, **kwargs)

dohq_artifactory/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import jwt
99
from dateutil.parser import isoparse
1010

11-
from dohq_artifactory.compat import * # noqa: this helper only contains version flags
11+
from dohq_artifactory.compat import IS_PYTHON_2
12+
from dohq_artifactory.compat import IS_PYTHON_3_6_OR_NEWER
1213
from dohq_artifactory.exception import ArtifactoryException
1314
from dohq_artifactory.exception import raise_for_status
1415
from dohq_artifactory.logger import logger

dohq_artifactory/compat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
# see changes in pathlib.Path, slots are no more applied
66
# https://github.com/python/cpython/blob/ce121fd8755d4db9511ce4aab39d0577165e118e/Lib/pathlib.py#L952
77
IS_PYTHON_3_10_OR_NEWER = sys.version_info >= (3, 10)
8+
# Pathlib.Path changed significantly in 3.12, so we will not need several
9+
# parts of the code once python3.11 is no longer supported. This constant helps
10+
# identifying those.
11+
IS_PYTHON_3_12_OR_NEWER = sys.version_info >= (3, 12)

0 commit comments

Comments
 (0)