Skip to content

Fix a number of Deprecated/Invalid escape sequences - #7925

Merged
NelleV merged 2 commits into
matplotlib:masterfrom
Carreau:deprecations
Feb 2, 2017
Merged

NelleV merged 2 commits into
matplotlib:masterfrom
Carreau:deprecations

Conversation

@Carreau

@Carreau Carreau commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

And turn python 3.6 DeprecationWarnings into error during tests.

Python 3.6 deprecate invalid escape sequences, as they are (most of the
time) mistakes from the author. This introduce extra \ when necessary,
or make strings raw.

See #7924

Comment thread lib/matplotlib/backends/backend_ps.py Outdated
from __future__ import (absolute_import, division, print_function,
unicode_literals)


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unnecessary change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, autopep8 script doing more than asked.

else:
pstoeps(tmpfile)


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should not be changed.

Comment thread lib/matplotlib/font_manager.py Outdated
looked up from the registry key::

\\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts
\\HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Fonts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The first one is supposed to be doubled, so it should be 4 when escaped, but maybe it'd be simpler to make it a raw string instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh.. ok, I did not remembered \\ was a thing on windows.

Comment thread lib/matplotlib/mathtext.py Outdated
('\rightbrace', '}'),
('\leftbracket', '['),
('\rightbracket', ']'),
for alias, target in [('\\leftparen', '('),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The last ones are raw strings; better to do that for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure. Done.

Comment thread lib/matplotlib/patches.py Outdated
styles. Used to update the documentation.
"""
names, attrss, clss = [], [], []
ddnames, attrss, clss = [], [], []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hum.. vim, probably though I was typing in another window.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

though these 3 attributes are not use at all in the function...

Comment thread lib/matplotlib/tests/test_subplots.py Outdated
with warnings.catch_warnings():
warnings.filterwarnings('ignore',
message='.*sharex\ argument\ to\ subplots',
message=r'.*sharex\ argument\ to\ subplots',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is \ ? I don't think this escape even means anything in a regular expression.

Comment thread lib/matplotlib/tests/test_text.py Outdated
warnings.filterwarnings(
'ignore',
('findfont: Font family \[u?\'Foo\'\] not found. Falling back to .'),
r'findfont: Font family \[u?\'Foo\'\] not found. Falling back to .',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the internal quotes no longer need to be escaped here now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use double quotes instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Err, actually, I don't know what I was thinking here, but the internal quotes still need to be escaped unless using double quotes as @anntzer suggested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Carreau As mentioned just above, can you switch to double quotes and remove the backslashes in the inner single quotes here?

Comment thread tests.py Outdated

# Python 3.6 deprecate invalid character-pairs \A, \* ... in non raw-strings
# and other things. Let's not re-introduce them
warnings.filterwarnings('error', category=DeprecationWarning)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Though I prefer not to introduce any deprecations either, this seems a bit broad for this PR.

@codecov-io

codecov-io commented Jan 23, 2017 •

Copy link
Copy Markdown

Current coverage is 62.18% (diff: 100%)

Merging #7925 into master will not change coverage

@@             master      #7925   diff @@
==========================================
  Files           175        175          
  Lines         56125      56125          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          34901      34901          
  Misses        21224      21224          
  Partials          0          0          

Powered by Codecov. Last update c93142f...582d771

Comment thread tests.py Outdated

# The warnings need to be before any of matplotlib imports, but after
# setuptools (if present) which has syntax error with the warnings enabled.
# Filtering by module does not work as this will be raise by Python itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo: raised

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Carreau
Carreau force-pushed the deprecations branch 2 times, most recently from c24f837 to ff6afaf Compare January 25, 2017 00:21
@Carreau

Carreau commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

Rebased to remove conflicts.

@Carreau

Carreau commented Jan 27, 2017

Copy link
Copy Markdown
Contributor Author

Rebased again and use backtick

@NelleV NelleV left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍
Thanks @Carreau

@NelleV NelleV changed the title Fix a number of Deprecated/Invalid escape sequences [MRG+1] Fix a number of Deprecated/Invalid escape sequences Jan 29, 2017
Comment thread tests.py
'default',
'.*inspect.getargspec\(\) is deprecated.*',
category=DeprecationWarning)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only gets executed when running tests.py, and I think most tests have been migrated to pytest now. Is there a way to make pytest execute these filterwarnings calls?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's supposed to get folded into Pytest itself at some point.

Comment thread lib/matplotlib/collections.py Outdated

/ - diagonal hatching
\ - back diagonal
\\ - back diagonal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one worries me as it is something I would expect to be read either on the web or in the terminal. Probably better to make this a r''' string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and I may be wrong here, escaping always ties me in knots....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I can't rebuild matplotlib today apparently, so can't test the html versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I managed to build the docs, and the \ in Accept below needed to be escaped more.
That should be fixed.

And turn python 3.6 DeprecationWarnings into error during tests.

Python 3.6 deprecate invalid escape sequences, as they are (most of the
time) mistakes from the author. This introduce extra `\` when necessary,
or make strings `raw`.

See matplotlib#7924
for each member.
ACCEPTS: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
ACCEPTS: [ '/' | '\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It appears that this line is under 79 characters and this file now passes PEP8, so it needs to be removed from lib/matplotlib/tests/test_coding_standards.py because the build is failing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, since you're going to have to push an update, I cancelled the OSX build which has been waiting for a while because we've got a long backlog.

@anntzer anntzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor nitpick.

Comment thread lib/matplotlib/tests/test_text.py Outdated
warnings.filterwarnings(
'ignore',
('findfont: Font family \[u?\'Foo\'\] not found. Falling back to .'),
r'findfont: Font family \[u?\'Foo\'\] not found. Falling back to .',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Carreau As mentioned just above, can you switch to double quotes and remove the backslashes in the inner single quotes here?

@NelleV

NelleV commented Feb 2, 2017

Copy link
Copy Markdown
Member

Thanks @Carreau
4 core dev validating your PR: I believe this is a new record :)

@NelleV
NelleV merged commit 924d913 into matplotlib:master Feb 2, 2017
@Carreau

Carreau commented Feb 2, 2017 via email

Copy link
Copy Markdown
Contributor Author

@QuLogic QuLogic changed the title [MRG+1] Fix a number of Deprecated/Invalid escape sequences Fix a number of Deprecated/Invalid escape sequences Feb 2, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Feb 2, 2017
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.

7 participants