sanic-cors icon indicating copy to clipboard operation
sanic-cors copied to clipboard

Deprecation warning due to invalid escape sequences

Open tirkarthi opened this issue 4 years ago • 2 comments

Deprecation warning due to invalid escape sequences. Using raw strings or escaping them again helps in resolving this. Check https://github.com/asottile/pyupgrade/ for automatic fix of this.

find . -iname '*.py' | grep -Ev 'setup|rdf4|tool' | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./tests/extension/test_app_extension.py:43: DeprecationWarning: invalid escape sequence \w
  re.compile('/test_compiled_subdomain_\w*'): {
./tests/extension/test_app_extension.py:44: DeprecationWarning: invalid escape sequence \d
  'origins': re.compile("http://example\d+.com")
./tests/core/helper_tests.py:90: DeprecationWarning: invalid escape sequence \w
  self.assertTrue(probably_regex("http://[\w].example.com"))
./tests/core/helper_tests.py:91: DeprecationWarning: invalid escape sequence \w
  self.assertTrue(probably_regex("http://\w+.example.com"))

tirkarthi avatar Apr 24 '20 12:04 tirkarthi

Hi @tirkarthi Is this on python 3.8? This is a section of code straight from Flask-CORS, untouched from when I ported it to sanic. I might be able to make some changes to get rid of the warning.

ashleysommer avatar Apr 25 '20 00:04 ashleysommer

I tested it on 3.8 but 3.7 also emits warnings. I didn't know it was vendored from flask-cors. I have a PR open for this upstream https://github.com/corydolphin/flask-cors/pull/260 . Feel free to close this if you are planning to vendor it once upstream is fixed. Thanks.

tirkarthi avatar Apr 25 '20 04:04 tirkarthi