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 deprecation warnings due to escape characters #371

Merged
merged 2 commits into from
Nov 6, 2019

Conversation

kitchoi
Copy link
Contributor

@kitchoi kitchoi commented Nov 6, 2019

This PR fixes deprecation warnings while running a test suite in a downstream project depending on enable.

It is not easy to pin point exactly where this gets trigger: I believe this is triggered by some import side-effects and the warning only appears once after every time my Python environment is rebuilt.

For example:

$ python -m unittest -v package.TestGUI.test_gui_lifecycle
test_gui_lifecycle (package.TestGUI) ... 
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/kiva/fonttools/font_manager.py:288: DeprecationWarning: invalid escape sequence \S
  """
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:113: DeprecationWarning: invalid escape sequence \s
  "\s*"                                                 # whitespace
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:115: DeprecationWarning: invalid escape sequence \s
  "\s*:\s*"                                             # whitespace : whitespace
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:117: DeprecationWarning: invalid escape sequence \.
  "([0-9]+)\.([0-9]+)(F))"      # ...formatchar
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:118: DeprecationWarning: invalid escape sequence \s
  "\s*"                                                 # whitespace
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:123: DeprecationWarning: invalid escape sequence \s
  _extraRE = re.compile("\s*([x@=<>!])\s*(#.*)?$")
/Users/kchoi/.edm/envs/envname/lib/python3.6/site-packages/fontTools/misc/sstruct.py:126: DeprecationWarning: invalid escape sequence \s
  _emptyRE = re.compile("\s*(#.*)?$")

Running the command again does not trigger the warnings.

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

LGTM

@mdickinson
Copy link
Member

I believe this is triggered by some import side-effects

Right, these are annoying to track down because (unlike most other warnings) they're triggered at compile time - i.e., .pyc-file generation time. If you remove the .pyc files and try again, you should see the warnings reappear.

@mdickinson
Copy link
Member

FWIW, flake8 can find these efficiently: you can run it to target just the one relevant warning, and then it should find all occurrences at once.

@mdickinson
Copy link
Member

Here's what I see from flake8:

mirzakhani:enable mdickinson$ flake8 --select=W605 .
./enable/events.py:74:54: W605 invalid escape sequence '\*'
./kiva/cairo.py:132:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:133:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:134:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:135:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:139:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:140:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:142:9: W605 invalid escape sequence '\*'
./kiva/cairo.py:155:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:157:11: W605 invalid escape sequence '\*'
./kiva/cairo.py:165:9: W605 invalid escape sequence '\*'
./kiva/agg/freetype2/src/tools/chktrcmp.py:52:34: W605 invalid escape sequence '\.'
./kiva/agg/freetype2/src/tools/chktrcmp.py:77:55: W605 invalid escape sequence '\('
./kiva/agg/freetype2/src/tools/chktrcmp.py:78:38: W605 invalid escape sequence '\)'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:168:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:169:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:170:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:171:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:172:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:173:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:174:43: W605 invalid escape sequence '\#'
./kiva/agg/freetype2/src/tools/docmaker/sources.py:175:43: W605 invalid escape sequence '\#'
./kiva/tests/agg/test_image3.py:193:21: W605 invalid escape sequence '\:'
./kiva/fonttools/sstruct.py:137:24: W605 invalid escape sequence '\s'
./kiva/fonttools/sstruct.py:137:37: W605 invalid escape sequence '\s'
./kiva/fonttools/sstruct.py:141:24: W605 invalid escape sequence '\s'

@kitchoi
Copy link
Contributor Author

kitchoi commented Nov 6, 2019

That makes sense. Thanks. I can go over all these occurrences and update them all as it is well within scope for this PR, then request review again. Does this sound good?

@mdickinson
Copy link
Member

Does this sound good?

SVGTM

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

LGTM, and I confirm that I no longer see any W605 flake8 warnings on this branch on my machine.

@kitchoi
Copy link
Contributor Author

kitchoi commented Nov 6, 2019

Thank you! Merging...

@kitchoi kitchoi merged commit f852ec9 into master Nov 6, 2019
@kitchoi kitchoi deleted the fix-deprecation-warning branch November 6, 2019 16:34
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.

3 participants