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

Fix warnings about invalid escape sequences #180

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _connect():
exit(1)

def handle_editor_command(self, text):
"""Editor command is any query that is prefixed or suffixed by a '\e'.
R"""Editor command is any query that is prefixed or suffixed by a '\e'.
The reason for a while loop is because a user might edit a query
multiple times. For eg:
Expand Down
8 changes: 4 additions & 4 deletions litecli/packages/parseutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# This matches everything except spaces, parens, colon, comma, and period
"most_punctuations": re.compile(r"([^\.():,\s]+)$"),
# This matches everything except a space.
"all_punctuations": re.compile("([^\s]+)$"),
"all_punctuations": re.compile(r"([^\s]+)$"),
}


def last_word(text, include="alphanum_underscore"):
"""
R"""
Find the last word in a sentence.
>>> last_word('abc')
Expand All @@ -41,9 +41,9 @@ def last_word(text, include="alphanum_underscore"):
>>> last_word('bac $def', include='most_punctuations')
'$def'
>>> last_word('bac \def', include='most_punctuations')
'\\\\def'
'\\def'
>>> last_word('bac \def;', include='most_punctuations')
'\\\\def;'
'\\def;'
>>> last_word('bac::def', include='most_punctuations')
'def'
"""
Expand Down
4 changes: 2 additions & 2 deletions litecli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_editor_query(sql):
# The reason we can't simply do .strip('\e') is that it strips characters,
# not a substring. So it'll strip "e" in the end of the sql also!
# Ex: "select * from style\e" -> "select * from styl".
pattern = re.compile("(^\\\e|\\\e$)")
pattern = re.compile(r"(^\\e|\\e$)")
while pattern.search(sql):
sql = pattern.sub("", sql)

Expand Down Expand Up @@ -245,7 +245,7 @@ def subst_favorite_query_args(query, args):
+ query,
]

match = re.search("\\?|\\$\d+", query)
match = re.search(r"\?|\$\d+", query)
if match:
return [
None,
Expand Down
2 changes: 1 addition & 1 deletion litecli/sqlcompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(self, supported_formats=(), keyword_casing="auto"):
self.reserved_words = set()
for x in self.keywords:
self.reserved_words.update(x.split())
self.name_pattern = compile("^[_a-z][_a-z0-9\$]*$")
self.name_pattern = compile(r"^[_a-z][_a-z0-9\$]*$")

self.special_commands = []
self.table_formats = supported_formats
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sqlexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def test_favorite_query_expanded_output(executor):
results = run(executor, "\\fs test-ae select * from test")
assert_result_equal(results, status="Saved.")

results = run(executor, "\\f+ test-ae \G")
results = run(executor, R"\f+ test-ae \G")
assert is_expanded_output() is True
assert_result_equal(
results,
Expand Down
Loading