scylladb / python-driver

ScyllaDB Python Driver, originally DataStax Python Driver for Apache Cassandra
https://python-driver.docs.scylladb.com
Apache License 2.0
70 stars 42 forks source link

cassandra/cluster.py: use raw string when appropriate #323

Closed tchaikov closed 2 months ago

tchaikov commented 3 months ago

Python complains at seeing

re.compile(r'^\s*BEGIN\s+[a-zA-Z]*\s*BATCH', re.UNICODE)
<>:1: SyntaxWarning: invalid escape sequence '\s'

but the interpreter continues on, and take "\s" as it is without escaping it. still, it's not a valid string literal.

because "\s" is not an escape sequence, while "\s" is, but we don't have to escape "\" here, we can just use the raw string. simpler this way.

in this change, we trade the invalid escape sequence with a raw string to silence this warning.

tchaikov commented 3 months ago

@Lorak-mmk hi Karol, could you help review this change?

fruch commented 3 months ago

it's funny, I've run into this today (but didn't had time to chase it), thanks @tchaikov

tchaikov commented 2 months ago

@fruch hi Israel, could you help merge this change?