Skip to content

Commit

Permalink
Fix invalid escape sequence warning
Browse files Browse the repository at this point in the history
Summary: Python starts warning in 3.6+ about invalid escape sequences in
strings. These regexes currently trigger that warning, but we can fix
that easily by converting them to raw strings instead.

Test Plan: For each string changed, tested that '$str' == r'$str' in the
python shell. ran tox and confirmed it still passed for py37, py38,
py39 and py310
  • Loading branch information
benhiller committed Sep 8, 2023
1 parent c1855c5 commit fb0b88e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion titlecase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def titlecase(text, callback=None, small_first_last=True, preserve_blank_lines=F
# too short (like "St", don't apply this)
CONSONANTS = ''.join(set(string.ascii_lowercase)
- {'a', 'e', 'i', 'o', 'u', 'y'})
is_all_consonants = regex.search('\A[' + CONSONANTS + ']+\Z', word,
is_all_consonants = regex.search(r'\A[' + CONSONANTS + r']+\Z', word,
flags=regex.IGNORECASE)
if is_all_consonants and len(word) > 2:
tc_line.append(word.upper())
Expand Down

0 comments on commit fb0b88e

Please sign in to comment.