Skip to content

Commit 237d269

Browse files
committed
Remove Python 2 compatibility code
The driver requires Python 3.10+ so these compatibility shims are no longer needed: - Remove try/except for Queue vs queue (use queue directly) - Remove try/except for __builtin__ vs builtins (use builtins directly) - Remove try/except for thread vs _thread (use _thread directly) - Remove try/except for futures vs concurrent.futures (use concurrent.futures directly) - Remove try/except for unittest2 vs unittest (use unittest directly) - Replace deprecated imp.reload with importlib.reload
1 parent 1dcec87 commit 237d269

6 files changed

Lines changed: 11 additions & 35 deletions

File tree

tests/integration/long/test_large_data.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
try:
16-
from Queue import Queue, Empty
17-
except ImportError:
18-
from queue import Queue, Empty # noqa
15+
from queue import Queue, Empty
1916

2017
from struct import pack
2118
import logging, sys, traceback, time

tests/integration/standard/test_shard_aware.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@
1717
from subprocess import run
1818
import logging
1919

20-
try:
21-
from concurrent.futures import ThreadPoolExecutor, as_completed
22-
except ImportError:
23-
from futures import ThreadPoolExecutor, as_completed # noqa
24-
25-
try:
26-
import unittest2 as unittest
27-
except ImportError:
28-
import unittest # noqa
20+
from concurrent.futures import ThreadPoolExecutor, as_completed
21+
22+
import unittest
2923
import pytest
3024

3125
from cassandra.cluster import Cluster

tests/integration/standard/test_use_keyspace.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import time
33
import logging
44

5-
try:
6-
import unittest2 as unittest
7-
except ImportError:
8-
import unittest # noqa
5+
import unittest
96

107
from unittest.mock import patch
118

tests/unit/io/eventlet_utils.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616
import os
1717
import select
1818
import socket
19-
try:
20-
import thread
21-
import Queue
22-
import __builtin__
23-
#For python3 compatibility
24-
except ImportError:
25-
import _thread as thread
26-
import queue as Queue
27-
import builtins as __builtin__
19+
import _thread as thread
20+
import queue as Queue
21+
import builtins as __builtin__
2822

2923
import threading
3024
import ssl
3125
import time
3226
import eventlet
33-
from imp import reload
27+
from importlib import reload
3428

3529
def eventlet_un_patch_all():
3630
"""

tests/unit/test_protocol_features.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
import unittest2 as unittest
3-
except ImportError:
4-
import unittest # noqa
1+
import unittest
52

63
import logging
74

tests/unit/test_shard_aware.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
try:
16-
import unittest2 as unittest
17-
except ImportError:
18-
import unittest # noqa
15+
import unittest
1916

2017
import logging
2118
from unittest.mock import MagicMock

0 commit comments

Comments
 (0)