Skip to content

Commit d0e639b

Browse files
Lorak-mmkvgali7
andauthored
Remove some remnants of Python2 (#1172)
Co-authored-by: vgali7 <[email protected]>
1 parent e9136f4 commit d0e639b

File tree

109 files changed

+410
-984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+410
-984
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ tests/unit/cython/bytesio_testhelper.c
4242
#iPython
4343
*.ipynb
4444

45+
venv
46+
docs/venv
47+
.eggs

CONTRIBUTING.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ To protect the community, all contributors are required to `sign the DataStax Co
2626

2727
Design and Implementation Guidelines
2828
------------------------------------
29-
- We support Python 2.7+, so any changes must work in any of these runtimes (we use ``six``, ``futures``, and some internal backports for compatability)
3029
- We have integrations (notably Cassandra cqlsh) that require pure Python and minimal external dependencies. We try to avoid new external dependencies. Where compiled extensions are concerned, there should always be a pure Python fallback implementation.
3130
- This project follows `semantic versioning <http://semver.org/>`_, so breaking API changes will only be introduced in major versions.
3231
- Legacy ``cqlengine`` has varying degrees of overreaching client-side validation. Going forward, we will avoid client validation where server feedback is adequate and not overly expensive.

appveyor.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
environment:
22
matrix:
3-
- PYTHON: "C:\\Python27-x64"
4-
cassandra_version: 3.11.2
5-
ci_type: standard
6-
- PYTHON: "C:\\Python35-x64"
3+
- PYTHON: "C:\\Python37-x64"
74
cassandra_version: 3.11.2
85
ci_type: standard
96
os: Visual Studio 2015

benchmarks/callback_full_pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from threading import Event
1919

2020
from base import benchmark, BenchmarkThread
21-
from six.moves import range
2221

2322
log = logging.getLogger(__name__)
2423

benchmarks/future_batches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logging
1616
from base import benchmark, BenchmarkThread
17-
from six.moves import queue
17+
import queue
1818

1919
log = logging.getLogger(__name__)
2020

benchmarks/future_full_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logging
1616
from base import benchmark, BenchmarkThread
17-
from six.moves import queue
17+
import queue
1818

1919
log = logging.getLogger(__name__)
2020

benchmarks/sync.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
from base import benchmark, BenchmarkThread
16-
from six.moves import range
1716

1817

1918
class Runner(BenchmarkThread):

cassandra/auth.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
except ImportError:
3333
SASLClient = None
3434

35-
import six
36-
3735
log = logging.getLogger(__name__)
3836

3937
# Custom payload keys related to DSE Unified Auth
@@ -270,15 +268,15 @@ def __init__(self, username, password):
270268
self.password = password
271269

272270
def get_mechanism(self):
273-
return six.b("PLAIN")
271+
return b"PLAIN"
274272

275273
def get_initial_challenge(self):
276-
return six.b("PLAIN-START")
274+
return b"PLAIN-START"
277275

278276
def evaluate_challenge(self, challenge):
279-
if challenge == six.b('PLAIN-START'):
277+
if challenge == b'PLAIN-START':
280278
data = "\x00%s\x00%s" % (self.username, self.password)
281-
return data if six.PY2 else data.encode()
279+
return data.encode()
282280
raise Exception('Did not receive a valid challenge response from server')
283281

284282

@@ -297,13 +295,13 @@ def __init__(self, host, service, qops, properties):
297295
self.sasl = SASLClient(host, service, 'GSSAPI', qops=qops, **properties)
298296

299297
def get_mechanism(self):
300-
return six.b("GSSAPI")
298+
return b"GSSAPI"
301299

302300
def get_initial_challenge(self):
303-
return six.b("GSSAPI-START")
301+
return b"GSSAPI-START"
304302

305303
def evaluate_challenge(self, challenge):
306-
if challenge == six.b('GSSAPI-START'):
304+
if challenge == b'GSSAPI-START':
307305
return self.sasl.process()
308306
else:
309307
return self.sasl.process(challenge)

cassandra/cluster.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import atexit
2222
from binascii import hexlify
2323
from collections import defaultdict
24+
from collections.abc import Mapping
2425
from concurrent.futures import ThreadPoolExecutor, FIRST_COMPLETED, wait as wait_futures
2526
from copy import copy
2627
from functools import partial, wraps
@@ -29,8 +30,8 @@
2930
import logging
3031
from warnings import warn
3132
from random import random
32-
import six
33-
from six.moves import filter, range, queue as Queue
33+
import re
34+
import queue
3435
import socket
3536
import sys
3637
import time
@@ -79,7 +80,6 @@
7980
HostTargetingStatement)
8081
from cassandra.marshal import int64_pack
8182
from cassandra.timestamps import MonotonicTimestampGenerator
82-
from cassandra.compat import Mapping
8383
from cassandra.util import _resolve_contact_points_to_string_map, Version
8484

8585
from cassandra.datastax.insights.reporter import MonitorReporter
@@ -111,9 +111,6 @@
111111
except ImportError:
112112
from cassandra.util import WeakSet # NOQA
113113

114-
if six.PY3:
115-
long = int
116-
117114
def _is_eventlet_monkey_patched():
118115
if 'eventlet.patcher' not in sys.modules:
119116
return False
@@ -1158,7 +1155,7 @@ def __init__(self,
11581155
else:
11591156
self._contact_points_explicit = True
11601157

1161-
if isinstance(contact_points, six.string_types):
1158+
if isinstance(contact_points, str):
11621159
raise TypeError("contact_points should not be a string, it should be a sequence (e.g. list) of strings")
11631160

11641161
if None in contact_points:
@@ -1793,8 +1790,8 @@ def _new_session(self, keyspace):
17931790
return session
17941791

17951792
def _session_register_user_types(self, session):
1796-
for keyspace, type_map in six.iteritems(self._user_types):
1797-
for udt_name, klass in six.iteritems(type_map):
1793+
for keyspace, type_map in self._user_types.items():
1794+
for udt_name, klass in type_map.items():
17981795
session.user_type_registered(keyspace, udt_name, klass)
17991796

18001797
def _cleanup_failed_on_up_handling(self, host):
@@ -2683,7 +2680,7 @@ def execute_async(self, query, parameters=None, trace=False, custom_payload=None
26832680
"""
26842681
custom_payload = custom_payload if custom_payload else {}
26852682
if execute_as:
2686-
custom_payload[_proxy_execute_key] = six.b(execute_as)
2683+
custom_payload[_proxy_execute_key] = execute_as.encode()
26872684

26882685
future = self._create_response_future(
26892686
query, parameters, trace, custom_payload, timeout,
@@ -2747,8 +2744,8 @@ def execute_graph_async(self, query, parameters=None, trace=False, execution_pro
27472744

27482745
custom_payload = execution_profile.graph_options.get_options_map()
27492746
if execute_as:
2750-
custom_payload[_proxy_execute_key] = six.b(execute_as)
2751-
custom_payload[_request_timeout_key] = int64_pack(long(execution_profile.request_timeout * 1000))
2747+
custom_payload[_proxy_execute_key] = execute_as.encode()
2748+
custom_payload[_request_timeout_key] = int64_pack(int(execution_profile.request_timeout * 1000))
27522749

27532750
future = self._create_response_future(query, parameters=None, trace=trace, custom_payload=custom_payload,
27542751
timeout=_NOT_SET, execution_profile=execution_profile)
@@ -2885,7 +2882,7 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
28852882

28862883
prepared_statement = None
28872884

2888-
if isinstance(query, six.string_types):
2885+
if isinstance(query, str):
28892886
query = SimpleStatement(query)
28902887
elif isinstance(query, PreparedStatement):
28912888
query = query.bind(parameters)
@@ -3353,10 +3350,6 @@ def user_type_registered(self, keyspace, user_type, klass):
33533350
'User type %s does not exist in keyspace %s' % (user_type, keyspace))
33543351

33553352
field_names = type_meta.field_names
3356-
if six.PY2:
3357-
# go from unicode to string to avoid decode errors from implicit
3358-
# decode when formatting non-ascii values
3359-
field_names = [fn.encode('utf-8') for fn in field_names]
33603353

33613354
def encode(val):
33623355
return '{ %s }' % ' , '.join('%s : %s' % (
@@ -4035,7 +4028,7 @@ def _get_schema_mismatches(self, peers_result, local_result, local_address):
40354028
log.debug("[control connection] Schemas match")
40364029
return None
40374030

4038-
return dict((version, list(nodes)) for version, nodes in six.iteritems(versions))
4031+
return dict((version, list(nodes)) for version, nodes in versions.items())
40394032

40404033
def _get_peers_query(self, peers_query_type, connection=None):
40414034
"""
@@ -4155,7 +4148,7 @@ class _Scheduler(Thread):
41554148
is_shutdown = False
41564149

41574150
def __init__(self, executor):
4158-
self._queue = Queue.PriorityQueue()
4151+
self._queue = queue.PriorityQueue()
41594152
self._scheduled_tasks = set()
41604153
self._count = count()
41614154
self._executor = executor
@@ -4213,7 +4206,7 @@ def run(self):
42134206
else:
42144207
self._queue.put_nowait((run_at, i, task))
42154208
break
4216-
except Queue.Empty:
4209+
except queue.Empty:
42174210
pass
42184211

42194212
time.sleep(0.1)

cassandra/compat.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)