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

Prefix regexes with r to avoid 'invalid escape sequence' Deprecation warnings #3055

Merged

Conversation

tomaarsen
Copy link
Member

Hello!

Pull request overview

  • Prefix some regexes in docstrings with r.

Details

See this GitHub Action for the source of these warnings:

nltk/tokenize/regexp.py::nltk.tokenize.regexp
  <doctest nltk.tokenize.regexp[2]>:1: DeprecationWarning: invalid escape sequence '\w'

nltk/tokenize/regexp.py::nltk.tokenize.regexp
  <doctest nltk.tokenize.regexp[4]>:1: DeprecationWarning: invalid escape sequence '\s'

nltk/tokenize/regexp.py::nltk.tokenize.regexp
  <doctest nltk.tokenize.regexp[6]>:1: DeprecationWarning: invalid escape sequence '\w'

nltk/tokenize/regexp.py::nltk.tokenize.regexp
  <doctest nltk.tokenize.regexp[11]>:1: DeprecationWarning: invalid escape sequence '\w'

nltk/tokenize/regexp.py::nltk.tokenize.regexp.RegexpTokenizer
  <doctest nltk.tokenize.regexp.RegexpTokenizer[0]>:1: DeprecationWarning: invalid escape sequence '\w'

This PR fixes these by prefixing r to these strings, turning them into "raw" strings, which is preferred for strings that represent regexes.

  • Tom Aarsen

@stevenbird stevenbird merged commit 720ba44 into nltk:develop Sep 29, 2022
@tomaarsen tomaarsen deleted the deprecate/invalid_escape_sequence branch September 29, 2022 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants