Skip to content

Commit

Permalink
Fix wrong escape sequences
Browse files Browse the repository at this point in the history
Following warnings shows up all over the code:
```
cassandra/cqlengine/connection.py:318: SyntaxWarning: invalid escape sequence '\*'
```
Let's fix it.
  • Loading branch information
dkropachev committed Jan 5, 2025
1 parent d62eb38 commit 6a69ec7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cassandra/cqlengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ def setup(
retry_connect=False,
**kwargs):
"""
Setup a the driver connection used by the mapper
Setup the driver connection used by the mapper
:param list hosts: list of hosts, (``contact_points`` for :class:`cassandra.cluster.Cluster`)
:param str default_keyspace: The default keyspace to use
:param int consistency: The global default :class:`~.ConsistencyLevel` - default is the same as :attr:`.Session.default_consistency_level`
:param bool lazy_connect: True if should not connect until first use
:param bool retry_connect: True if we should retry to connect even if there was a connection failure initially
:param \*\*kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
:param kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
"""

from cassandra.cqlengine import models
Expand Down
8 changes: 4 additions & 4 deletions cassandra/cqlengine/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def add_callback(self, fn, *args, **kwargs):
:param fn: Callable object
:type fn: callable
:param \*args: Positional arguments to be passed to the callback at the time of execution
:param \*\*kwargs: Named arguments to be passed to the callback at the time of execution
:param args: Positional arguments to be passed to the callback at the time of execution
:param kwargs: Named arguments to be passed to the callback at the time of execution
"""
if not callable(fn):
raise ValueError("Value for argument 'fn' is {0} and is not a callable object.".format(type(fn)))
Expand Down Expand Up @@ -276,8 +276,8 @@ class ContextQuery(object):
A Context manager to allow a Model to switch context easily. Presently, the context only
specifies a keyspace for model IO.
:param \*args: One or more models. A model should be a class type, not an instance.
:param \*\*kwargs: (optional) Context parameters: can be *keyspace* or *connection*
:param args: One or more models. A model should be a class type, not an instance.
:param kwargs: (optional) Context parameters: can be *keyspace* or *connection*
For example:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_raise_error_on_control_connection_timeout(self):
get_node(1).pause()
cluster = TestCluster(contact_points=['127.0.0.1'], connect_timeout=1)

with self.assertRaisesRegex(NoHostAvailable, "OperationTimedOut\('errors=Timed out creating connection \(1 seconds\)"):
with self.assertRaisesRegex(NoHostAvailable, r"OperationTimedOut\('errors=Timed out creating connection \(1 seconds\)"):
cluster.connect()
cluster.shutdown()

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/standard/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ def test_function_no_parameters(self):

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

def test_functions_follow_keyspace_alter(self):
"""
Expand Down Expand Up @@ -1725,12 +1725,12 @@ def test_function_cql_called_on_null(self):
kwargs['called_on_null_input'] = True
with self.VerifiedFunction(self, **kwargs) as vf:
fn_meta = self.keyspace_function_meta[vf.signature]
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*")
self.assertRegex(fn_meta.as_cql_query(), r'CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*')

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


@requires_java_udf
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_client_ip_in_trace(self):
client_ip = trace.client

# Ip address should be in the local_host range
pat = re.compile("127.0.0.\d{1,3}")
pat = re.compile(r'127.0.0.\d{1,3}')

# Ensure that ip is set
self.assertIsNotNone(client_ip, "Client IP was not set in trace with C* >= 2.2")
Expand Down

0 comments on commit 6a69ec7

Please sign in to comment.