Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 30, 2024

Conversation

tchaikov
Copy link

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.

Python complains at seeing
```py
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.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov requested a review from Lorak-mmk May 20, 2024 06:42
@tchaikov
Copy link
Author

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

@roydahan roydahan requested a review from fruch May 20, 2024 10:16
Copy link

@fruch fruch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fruch
Copy link

fruch commented May 20, 2024

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

@tchaikov
Copy link
Author

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

@fruch fruch merged commit 82b4863 into scylladb:master May 30, 2024
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants