Skip to content

Commit 93fa5c9

Browse files
committed
fix several deprecation warnings
adding -Werror flag to pytest configuration so we can flush all of those with the test we have so we won't have user of the driver running into those and get them fixed address as soon as we support new python versions
1 parent 059e10e commit 93fa5c9

26 files changed

+100
-50
lines changed

cassandra/cqlengine/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def setup(
323323
:param int consistency: The global default :class:`~.ConsistencyLevel` - default is the same as :attr:`.Session.default_consistency_level`
324324
:param bool lazy_connect: True if should not connect until first use
325325
:param bool retry_connect: True if we should retry to connect even if there was a connection failure initially
326-
:param \*\*kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
326+
:param kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
327327
"""
328328

329329
from cassandra.cqlengine import models

cassandra/cqlengine/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def add_callback(self, fn, *args, **kwargs):
205205
206206
:param fn: Callable object
207207
:type fn: callable
208-
:param \*args: Positional arguments to be passed to the callback at the time of execution
209-
:param \*\*kwargs: Named arguments to be passed to the callback at the time of execution
208+
:param args: Positional arguments to be passed to the callback at the time of execution
209+
:param kwargs: Named arguments to be passed to the callback at the time of execution
210210
"""
211211
if not callable(fn):
212212
raise ValueError("Value for argument 'fn' is {0} and is not a callable object.".format(type(fn)))
@@ -276,8 +276,8 @@ class ContextQuery(object):
276276
A Context manager to allow a Model to switch context easily. Presently, the context only
277277
specifies a keyspace for model IO.
278278
279-
:param \*args: One or more models. A model should be a class type, not an instance.
280-
:param \*\*kwargs: (optional) Context parameters: can be *keyspace* or *connection*
279+
:param args: One or more models. A model should be a class type, not an instance.
280+
:param kwargs: (optional) Context parameters: can be *keyspace* or *connection*
281281
282282
For example:
283283

cassandra/datastax/cloud/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
_HAS_SSL = True
2424
try:
25-
from ssl import SSLContext, PROTOCOL_TLS, CERT_REQUIRED
25+
from ssl import SSLContext, PROTOCOL_TLS_CLIENT, CERT_REQUIRED
2626
except:
2727
_HAS_SSL = False
2828

@@ -169,7 +169,7 @@ def parse_metadata_info(config, http_data):
169169

170170

171171
def _ssl_context_from_cert(ca_cert_location, cert_location, key_location):
172-
ssl_context = SSLContext(PROTOCOL_TLS)
172+
ssl_context = SSLContext(PROTOCOL_TLS_CLIENT)
173173
ssl_context.load_verify_locations(ca_cert_location)
174174
ssl_context.verify_mode = CERT_REQUIRED
175175
ssl_context.load_cert_chain(certfile=cert_location, keyfile=key_location)

cassandra/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from cassandra import DriverException
4242

4343
DATETIME_EPOC = datetime.datetime(1970, 1, 1)
44-
UTC_DATETIME_EPOC = datetime.datetime.utcfromtimestamp(0)
44+
UTC_DATETIME_EPOC = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)
4545

4646
_nan = float('nan')
4747

pytest.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@ log_format = %(asctime)s.%(msecs)03d %(levelname)s [%(module)s:%(lineno)s]: %(me
33
log_level = DEBUG
44
log_date_format = %Y-%m-%d %H:%M:%S
55
xfail_strict=true
6+
7+
filterwarnings =
8+
error
9+
ignore::pytest.PytestCollectionWarning
10+
ignore::ResourceWarning
11+
ignore:distutils Version classes are deprecated:DeprecationWarning:eventlet.support.greenlets
12+
ignore:X509Extension support in pyOpenSSL is deprecated.:DeprecationWarning
13+
ignore:CRL support in pyOpenSSL is deprecated:DeprecationWarning
14+
ignore:sign\(\) is deprecated:DeprecationWarning
15+
ignore:verify\(\) is deprecated:DeprecationWarning
16+
ignore:pkg_resources is deprecated as an API:DeprecationWarning:gevent.events
17+
ignore:.*pkg_resources.declare_namespace.*:DeprecationWarning
18+
ignore:"@coroutine" decorator is deprecated since Python 3.8:DeprecationWarning:asynctest.*
19+
ignore:The asyncore module is deprecated and will be removed in Python 3.12:DeprecationWarning:asyncore.*

tests/integration/cqlengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def wrapped_function(*args, **kwargs):
7777
# DeMonkey Patch our code
7878
cassandra.cqlengine.connection.execute = original_function
7979
# Check to see if we have a pre-existing test case to work from.
80-
if len(args) is 0:
80+
if len(args) == 0:
8181
test_case = unittest.TestCase("__init__")
8282
else:
8383
test_case = args[0]

tests/integration/cqlengine/query/test_queryoperators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,6 @@ def test_named_table_pk_token_function(self):
154154
query = named.all().limit(1)
155155
first_page = list(query)
156156
last = first_page[-1]
157-
self.assertTrue(len(first_page) is 1)
157+
self.assertTrue(len(first_page) == 1)
158158
next_page = list(query.filter(pk__token__gt=functions.Token(last.key)))
159-
self.assertTrue(len(next_page) is 1)
159+
self.assertTrue(len(next_page) == 1)

tests/integration/standard/test_cluster.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Copyright DataStax, Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -150,7 +151,7 @@ def test_raise_error_on_control_connection_timeout(self):
150151
get_node(1).pause()
151152
cluster = TestCluster(contact_points=['127.0.0.1'], connect_timeout=1)
152153

153-
with self.assertRaisesRegex(NoHostAvailable, "OperationTimedOut\('errors=Timed out creating connection \(1 seconds\)"):
154+
with self.assertRaisesRegex(NoHostAvailable, r"OperationTimedOut\('errors=Timed out creating connection \(1 seconds\)"):
154155
cluster.connect()
155156
cluster.shutdown()
156157

tests/integration/standard/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def wait_for_connections(self, host, cluster):
180180
while(retry < 300):
181181
retry += 1
182182
connections = self.fetch_connections(host, cluster)
183-
if len(connections) is not 0:
183+
if len(connections) != 0:
184184
return connections
185185
time.sleep(.1)
186186
self.fail("No new connections found")
@@ -190,7 +190,7 @@ def wait_for_no_connections(self, host, cluster):
190190
while(retry < 100):
191191
retry += 1
192192
connections = self.fetch_connections(host, cluster)
193-
if len(connections) is 0:
193+
if len(connections) == 0:
194194
return
195195
time.sleep(.5)
196196
self.fail("Connections never cleared")

tests/integration/standard/test_metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ def test_function_no_parameters(self):
16751675

16761676
with self.VerifiedFunction(self, **kwargs) as vf:
16771677
fn_meta = self.keyspace_function_meta[vf.signature]
1678-
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*%s\(\) .*" % kwargs['name'])
1678+
self.assertRegex(fn_meta.as_cql_query(), r"CREATE FUNCTION.*%s\(\) .*" % kwargs['name'])
16791679

16801680
def test_functions_follow_keyspace_alter(self):
16811681
"""
@@ -1723,12 +1723,12 @@ def test_function_cql_called_on_null(self):
17231723
kwargs['called_on_null_input'] = True
17241724
with self.VerifiedFunction(self, **kwargs) as vf:
17251725
fn_meta = self.keyspace_function_meta[vf.signature]
1726-
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*")
1726+
self.assertRegex(fn_meta.as_cql_query(), r"CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*")
17271727

17281728
kwargs['called_on_null_input'] = False
17291729
with self.VerifiedFunction(self, **kwargs) as vf:
17301730
fn_meta = self.keyspace_function_meta[vf.signature]
1731-
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*")
1731+
self.assertRegex(fn_meta.as_cql_query(), r"CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*")
17321732

17331733

17341734
@requires_java_udf

0 commit comments

Comments
 (0)