Skip to content

Commit 818a453

Browse files
SG-43906 Remove Python 3.7/3.8 compatibility code (#454)
- Simplify the version guard in shotgun_api3/__init__.py to a single 3.9 check, matching the pattern already adopted in tk-core. - Remove the dead pre-3.8 branch in Shotgun._split_url(), which used the deprecated urllib.parse.splituser. setup.py already requires python_requires>=3.9.0, so both branches were unreachable.
1 parent 507b792 commit 818a453

2 files changed

Lines changed: 13 additions & 30 deletions

File tree

shotgun_api3/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import sys
1313
import warnings
1414

15-
if sys.version_info < (3, 7):
15+
if sys.version_info < (3, 9):
1616
if os.environ.get("SHOTGUN_ALLOW_OLD_PYTHON", "0") != "1":
1717
# This is our preferred default behavior when using an old
1818
# unsupported Python version.
@@ -21,25 +21,17 @@
2121
# Python traceback and trying to understand this is due to using an
2222
# unsupported Python version.
2323

24-
raise RuntimeError("This module requires Python version 3.7 or higher.")
24+
raise RuntimeError("This module requires Python version 3.9 or higher.")
2525

2626
warnings.warn(
27-
"Python versions older than 3.7 are no longer supported as of January "
28-
"2023. Since the SHOTGUN_ALLOW_OLD_PYTHON variable is enabled, this "
27+
"Python versions older than 3.9 are no longer supported as of March "
28+
"2025. Since the SHOTGUN_ALLOW_OLD_PYTHON variable is enabled, this "
2929
"module is raising a warning instead of an exception. "
3030
"However, it is very likely that this module will not be able to work "
3131
"on this Python version.",
3232
RuntimeWarning,
3333
stacklevel=2,
3434
)
35-
elif sys.version_info < (3, 9):
36-
warnings.warn(
37-
"Python versions older than 3.9 are no longer supported as of March "
38-
"2025 and compatibility will be discontinued after March 2026. "
39-
"Please update to Python 3.13 or any other supported version.",
40-
DeprecationWarning,
41-
stacklevel=2,
42-
)
4335

4436

4537
from .shotgun import (

shotgun_api3/shotgun.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -740,27 +740,18 @@ def _split_url(self, base_url: str) -> Tuple[Optional[str], Optional[str]]:
740740
"""
741741
Extract the hostname:port and username/password/token from base_url
742742
sent when connect to the API.
743-
744-
In python 3.8 `urllib.parse.splituser` was deprecated warning devs to
745-
use `urllib.parse.urlparse`.
746743
"""
747-
if (sys.version_info.major, sys.version_info.minor) >= (3, 8):
748-
auth = None
749-
results = urllib.parse.urlparse(base_url)
750-
server = results.hostname
751-
if results.port:
752-
server = "{}:{}".format(server, results.port)
753-
754-
if results.username:
755-
auth = results.username
744+
auth = None
745+
results = urllib.parse.urlparse(base_url)
746+
server = results.hostname
747+
if results.port:
748+
server = "{}:{}".format(server, results.port)
756749

757-
if results.password:
758-
auth = "{}:{}".format(auth, results.password)
750+
if results.username:
751+
auth = results.username
759752

760-
else:
761-
auth, server = urllib.parse.splituser(
762-
urllib.parse.urlsplit(base_url).netloc
763-
)
753+
if results.password:
754+
auth = "{}:{}".format(auth, results.password)
764755

765756
return auth, server
766757

0 commit comments

Comments
 (0)