Skip to content

Commit 45b6e5b

Browse files
committed
driver-six-binary_and_text_data_removal
1 parent 57e2eea commit 45b6e5b

31 files changed

+79
-109
lines changed

cassandra/auth.py

Lines changed: 6 additions & 8 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,13 +268,13 @@ def __init__(self, username, password):
270268
self.password = password
271269

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

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

278276
def evaluate_challenge(self, challenge):
279-
if challenge == six.b('PLAIN-START'):
277+
if challenge == 'PLAIN-START':
280278
data = "\x00%s\x00%s" % (self.username, self.password)
281279
return data.encode()
282280
raise Exception('Did not receive a valid challenge response from server')
@@ -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 "GSSAPI"
301299

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

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

cassandra/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ def execute_async(self, query, parameters=None, trace=False, custom_payload=None
26732673
"""
26742674
custom_payload = custom_payload if custom_payload else {}
26752675
if execute_as:
2676-
custom_payload[_proxy_execute_key] = six.b(execute_as)
2676+
custom_payload[_proxy_execute_key] = execute_as
26772677

26782678
future = self._create_response_future(
26792679
query, parameters, trace, custom_payload, timeout,
@@ -2737,7 +2737,7 @@ def execute_graph_async(self, query, parameters=None, trace=False, execution_pro
27372737

27382738
custom_payload = execution_profile.graph_options.get_options_map()
27392739
if execute_as:
2740-
custom_payload[_proxy_execute_key] = six.b(execute_as)
2740+
custom_payload[_proxy_execute_key] = execute_as
27412741
custom_payload[_request_timeout_key] = int64_pack(long(execution_profile.request_timeout * 1000))
27422742

27432743
future = self._create_response_future(query, parameters=None, trace=trace, custom_payload=custom_payload,

cassandra/datastax/graph/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def get_options_map(self, other_options=None):
103103
for cl in ('graph-write-consistency', 'graph-read-consistency'):
104104
cl_enum = options.get(cl)
105105
if cl_enum is not None:
106-
options[cl] = six.b(ConsistencyLevel.value_to_name[cl_enum])
106+
options[cl] = ConsistencyLevel.value_to_name[cl_enum]
107107
return options
108108

109109
def set_source_default(self):
@@ -158,7 +158,7 @@ def set(self, value, key=opt[2]):
158158
if value is not None:
159159
# normalize text here so it doesn't have to be done every time we get options map
160160
if isinstance(value, six.text_type) and not isinstance(value, six.binary_type):
161-
value = six.b(value)
161+
value = value
162162
self._graph_options[key] = value
163163
else:
164164
self._graph_options.pop(key, None)

cassandra/segment.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
import zlib
16-
import six
1716

1817
from cassandra import DriverException
1918
from cassandra.marshal import int32_pack

tests/integration/advanced/graph/test_graph.py

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

15-
import six
1615
import re
1716

1817
from cassandra import OperationTimedOut, InvalidRequest

tests/integration/advanced/graph/test_graph_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_consistency_passing(self):
8383
res = s.execute_graph("null")
8484

8585
for k, v in cl.items():
86-
self.assertEqual(res.response_future.message.custom_payload[graph_params[k]], six.b(ConsistencyLevel.value_to_name[v]))
86+
self.assertEqual(res.response_future.message.custom_payload[graph_params[k]], ConsistencyLevel.value_to_name[v])
8787

8888
# passed profile values override session defaults
8989
cl = {0: ConsistencyLevel.ALL, 1: ConsistencyLevel.QUORUM}
@@ -97,7 +97,7 @@ def test_consistency_passing(self):
9797
res = s.execute_graph("null", execution_profile=tmp_profile)
9898

9999
for k, v in cl.items():
100-
self.assertEqual(res.response_future.message.custom_payload[graph_params[k]], six.b(ConsistencyLevel.value_to_name[v]))
100+
self.assertEqual(res.response_future.message.custom_payload[graph_params[k]], ConsistencyLevel.value_to_name[v])
101101
finally:
102102
default_profile.graph_options = default_graph_opts
103103

tests/integration/cqlengine/columns/test_value_io.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from datetime import datetime, timedelta, time
1717
from decimal import Decimal
1818
from uuid import uuid1, uuid4, UUID
19-
import six
2019

2120
from cassandra.cqlengine import columns
2221
from cassandra.cqlengine.management import sync_table
@@ -101,15 +100,15 @@ def test_column_io(self):
101100
class TestBlobIO(BaseColumnIOTest):
102101

103102
column = columns.Blob
104-
pkey_val = six.b('blake'), uuid4().bytes
105-
data_val = six.b('eggleston'), uuid4().bytes
103+
pkey_val = 'blake', uuid4().bytes
104+
data_val = 'eggleston', uuid4().bytes
106105

107106

108107
class TestBlobIO2(BaseColumnIOTest):
109108

110109
column = columns.Blob
111-
pkey_val = bytearray(six.b('blake')), uuid4().bytes
112-
data_val = bytearray(six.b('eggleston')), uuid4().bytes
110+
pkey_val = bytearray('blake'), uuid4().bytes
111+
data_val = bytearray('eggleston'), uuid4().bytes
113112

114113

115114
class TestTextIO(BaseColumnIOTest):

tests/integration/cqlengine/management/test_management.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
import unittest
1515

16-
import six
1716
import mock
1817
import logging
1918
from packaging.version import Version

tests/integration/cqlengine/model/test_class_construction.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from uuid import uuid4
1616
import warnings
1717

18-
import six
1918
from cassandra.cqlengine import columns, CQLEngineException
2019
from cassandra.cqlengine.models import Model, ModelException, ModelDefinitionException, ColumnQueryEvaluator
2120
from cassandra.cqlengine.query import ModelQuerySet, DMLQuery

tests/integration/cqlengine/test_batch_query.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
import warnings
1515

16-
import six
1716
import sure
1817

1918
from cassandra.cqlengine import columns

tests/integration/long/test_ipv6.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
import os, socket, errno
16-
import six
1716
from ccmlib import common
1817

1918
from cassandra.cluster import NoHostAvailable

tests/integration/simulacron/test_connection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import unittest
1515

1616
import logging
17-
import six
1817
import time
1918

2019
from mock import Mock, patch

tests/integration/standard/test_authentication.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import logging
1717
import time
1818

19-
import six
2019
from cassandra.cluster import NoHostAvailable
2120
from cassandra.auth import PlainTextAuthProvider, SASLClient, SaslAuthProvider
2221

tests/integration/standard/test_client_warnings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import unittest
1717

18-
import six
1918
from cassandra.query import BatchStatement
2019

2120
from tests.integration import use_singledc, PROTOCOL_VERSION, local, TestCluster

tests/integration/standard/test_cluster.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import warnings
2424
from packaging.version import Version
2525

26-
import six
2726
import cassandra
2827
from cassandra.cluster import NoHostAvailable, ExecutionProfile, EXEC_PROFILE_DEFAULT, ControlConnection, Cluster
2928
from cassandra.concurrent import execute_concurrent

tests/integration/standard/test_custom_payload.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import unittest
1717

18-
import six
19-
2018
from cassandra.query import (SimpleStatement, BatchStatement, BatchType)
2119

2220
from tests.integration import use_singledc, PROTOCOL_VERSION, local, TestCluster
@@ -138,16 +136,16 @@ def validate_various_custom_payloads(self, statement):
138136

139137
# Long key value pair
140138
key_value = "x" * 10
141-
custom_payload = {key_value: six.b(key_value)}
139+
custom_payload = {key_value: key_value}
142140
self.execute_async_validate_custom_payload(statement=statement, custom_payload=custom_payload)
143141

144142
# Max supported value key pairs according C* binary protocol v4 should be 65534 (unsigned short max value)
145143
for i in range(65534):
146-
custom_payload[str(i)] = six.b('x')
144+
custom_payload[str(i)] = 'x'
147145
self.execute_async_validate_custom_payload(statement=statement, custom_payload=custom_payload)
148146

149147
# Add one custom payload to this is too many key value pairs and should fail
150-
custom_payload[str(65535)] = six.b('x')
148+
custom_payload[str(65535)] = 'x'
151149
with self.assertRaises(ValueError):
152150
self.execute_async_validate_custom_payload(statement=statement, custom_payload=custom_payload)
153151

tests/integration/standard/test_metadata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ class Ext1(Ext0):
990990
update_v = s.prepare('UPDATE system_schema.views SET extensions=? WHERE keyspace_name=? AND view_name=?')
991991
# extensions registered, one present
992992
# --------------------------------------
993-
ext_map = {Ext0.name: six.b("THA VALUE")}
993+
ext_map = {Ext0.name: "THA VALUE"}
994994
[(s.execute(update_t, (ext_map, ks, t)), s.execute(update_v, (ext_map, ks, v)))
995995
for _ in self.cluster.metadata.all_hosts()] # we're manipulating metadata - do it on all hosts
996996
self.cluster.refresh_table_metadata(ks, t)
@@ -1012,8 +1012,8 @@ class Ext1(Ext0):
10121012

10131013
# extensions registered, one present
10141014
# --------------------------------------
1015-
ext_map = {Ext0.name: six.b("THA VALUE"),
1016-
Ext1.name: six.b("OTHA VALUE")}
1015+
ext_map = {Ext0.name: "THA VALUE",
1016+
Ext1.name: "OTHA VALUE"}
10171017
[(s.execute(update_t, (ext_map, ks, t)), s.execute(update_v, (ext_map, ks, v)))
10181018
for _ in self.cluster.metadata.all_hosts()] # we're manipulating metadata - do it on all hosts
10191019
self.cluster.refresh_table_metadata(ks, t)
@@ -1238,8 +1238,8 @@ def test_replicas(self):
12381238

12391239
cluster.connect('test3rf')
12401240

1241-
self.assertNotEqual(list(cluster.metadata.get_replicas('test3rf', six.b('key'))), [])
1242-
host = list(cluster.metadata.get_replicas('test3rf', six.b('key')))[0]
1241+
self.assertNotEqual(list(cluster.metadata.get_replicas('test3rf', 'key')), [])
1242+
host = list(cluster.metadata.get_replicas('test3rf', 'key'))[0]
12431243
self.assertEqual(host.datacenter, 'dc1')
12441244
self.assertEqual(host.rack, 'r1')
12451245
cluster.shutdown()

tests/integration/standard/test_udts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def test_type_alteration(self):
718718
s.execute("INSERT INTO %s (k, v) VALUES (0, {v0 : 3, v1 : 0xdeadbeef})" % (self.table_name,))
719719
val = s.execute('SELECT v FROM %s' % self.table_name)[0][0]
720720
self.assertEqual(val['v0'], 3)
721-
self.assertEqual(val['v1'], six.b('\xde\xad\xbe\xef'))
721+
self.assertEqual(val['v1'], '\xde\xad\xbe\xef')
722722

723723
@lessthancass30
724724
def test_alter_udt(self):

tests/unit/advanced/cloud/test_cloud.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import tempfile
1010
import os
1111
import shutil
12-
import six
1312

1413
import unittest
1514

tests/unit/advanced/test_graph.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
import unittest
1919

20-
import six
21-
2220
from cassandra import ConsistencyLevel
2321
from cassandra.policies import RetryPolicy
2422
from cassandra.graph import (SimpleGraphStatement, GraphOptions, GraphProtocol, Result,
@@ -278,7 +276,7 @@ def test_get_options(self):
278276
other = GraphOptions(**kwargs)
279277
options = base.get_options_map(other)
280278
updated = self.opt_mapping['graph_name']
281-
self.assertEqual(options[updated], six.b('unit_test'))
279+
self.assertEqual(options[updated], 'unit_test')
282280
for name in (n for n in self.opt_mapping.values() if n != updated):
283281
self.assertEqual(options[name], base._graph_options[name])
284282

@@ -288,22 +286,22 @@ def test_get_options(self):
288286
def test_set_attr(self):
289287
expected = 'test@@@@'
290288
opts = GraphOptions(graph_name=expected)
291-
self.assertEqual(opts.graph_name, six.b(expected))
289+
self.assertEqual(opts.graph_name, expected)
292290
expected = 'somethingelse####'
293291
opts.graph_name = expected
294-
self.assertEqual(opts.graph_name, six.b(expected))
292+
self.assertEqual(opts.graph_name, expected)
295293

296294
# will update options with set value
297295
another = GraphOptions()
298296
self.assertIsNone(another.graph_name)
299297
another.update(opts)
300-
self.assertEqual(another.graph_name, six.b(expected))
298+
self.assertEqual(another.graph_name, expected)
301299

302300
opts.graph_name = None
303301
self.assertIsNone(opts.graph_name)
304302
# will not update another with its set-->unset value
305303
another.update(opts)
306-
self.assertEqual(another.graph_name, six.b(expected)) # remains unset
304+
self.assertEqual(another.graph_name, expected) # remains unset
307305
opt_map = another.get_options_map(opts)
308306
self.assertEqual(opt_map, another._graph_options)
309307

@@ -318,7 +316,7 @@ def _verify_api_params(self, opts, api_params):
318316
self.assertEqual(len(opts._graph_options), len(api_params))
319317
for name, value in api_params.items():
320318
try:
321-
value = six.b(value)
319+
value = value
322320
except:
323321
pass # already bytes
324322
self.assertEqual(getattr(opts, name), value)
@@ -335,8 +333,8 @@ def test_consistency_levels(self):
335333

336334
# mapping from base
337335
opt_map = opts.get_options_map()
338-
self.assertEqual(opt_map['graph-read-consistency'], six.b(ConsistencyLevel.value_to_name[read_cl]))
339-
self.assertEqual(opt_map['graph-write-consistency'], six.b(ConsistencyLevel.value_to_name[write_cl]))
336+
self.assertEqual(opt_map['graph-read-consistency'], ConsistencyLevel.value_to_name[read_cl])
337+
self.assertEqual(opt_map['graph-write-consistency'], ConsistencyLevel.value_to_name[write_cl])
340338

341339
# empty by default
342340
new_opts = GraphOptions()
@@ -346,8 +344,8 @@ def test_consistency_levels(self):
346344

347345
# set from other
348346
opt_map = new_opts.get_options_map(opts)
349-
self.assertEqual(opt_map['graph-read-consistency'], six.b(ConsistencyLevel.value_to_name[read_cl]))
350-
self.assertEqual(opt_map['graph-write-consistency'], six.b(ConsistencyLevel.value_to_name[write_cl]))
347+
self.assertEqual(opt_map['graph-read-consistency'], ConsistencyLevel.value_to_name[read_cl])
348+
self.assertEqual(opt_map['graph-write-consistency'], ConsistencyLevel.value_to_name[write_cl])
351349

352350
def test_graph_source_convenience_attributes(self):
353351
opts = GraphOptions()

tests/unit/cqlengine/test_connection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
import unittest
1616

17-
import six
18-
1917
from cassandra.cluster import _ConfigMode
2018
from cassandra.cqlengine import connection
2119
from cassandra.query import dict_factory

0 commit comments

Comments
 (0)