-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix a number of Deprecated/Invalid escape sequences #7925
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
Conversation
@@ -5,6 +5,7 @@ | |||
from __future__ import (absolute_import, division, print_function, | |||
unicode_literals) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary change.
There was a problem hiding this comment.
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.
@@ -1543,7 +1544,6 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False): | |||
else: | |||
pstoeps(tmpfile) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be changed.
lib/matplotlib/font_manager.py
Outdated
@@ -184,7 +184,7 @@ def win32FontDirectory(): | |||
Return the user-specified font directory for Win32. This is | |||
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
lib/matplotlib/mathtext.py
Outdated
('\rightbrace', '}'), | ||
('\leftbracket', '['), | ||
('\rightbracket', ']'), | ||
for alias, target in [('\\leftparen', '('), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. Done.
lib/matplotlib/patches.py
Outdated
@@ -1803,7 +1803,7 @@ def _pprint_styles(_styles): | |||
(stylename : styleclass), return a formatted string listing all the | |||
styles. Used to update the documentation. | |||
""" | |||
names, attrss, clss = [], [], [] | |||
ddnames, attrss, clss = [], [], [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
@@ -111,7 +111,7 @@ def test_exceptions(): | |||
# the point of this test is to ensure that this raises. | |||
with warnings.catch_warnings(): | |||
warnings.filterwarnings('ignore', | |||
message='.*sharex\ argument\ to\ subplots', | |||
message=r'.*sharex\ argument\ to\ subplots', |
There was a problem hiding this comment.
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.
lib/matplotlib/tests/test_text.py
Outdated
@@ -30,7 +30,7 @@ def find_matplotlib_font(**kw): | |||
from matplotlib.font_manager import FontProperties, findfont | |||
warnings.filterwarnings( | |||
'ignore', | |||
('findfont: Font family \[u?\'Foo\'\] not found. Falling back to .'), | |||
r'findfont: Font family \[u?\'Foo\'\] not found. Falling back to .', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double quotes instead?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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.
Current coverage is 62.18% (diff: 100%)@@ 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
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: raised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
c24f837
to
ff6afaf
Compare
Rebased to remove conflicts. |
Rebased again and use backtick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks @Carreau
'default', | ||
'.*inspect.getargspec\(\) is deprecated.*', | ||
category=DeprecationWarning) | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
lib/matplotlib/collections.py
Outdated
@@ -394,7 +394,7 @@ def set_hatch(self, hatch): | |||
*hatch* can be one of:: | |||
|
|||
/ - diagonal hatching | |||
\ - back diagonal | |||
\\ - back diagonal |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -415,7 +415,7 @@ def set_hatch(self, hatch): | |||
can only be specified for the collection as a whole, not separately | |||
for each member. | |||
|
|||
ACCEPTS: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ] | |||
ACCEPTS: [ '/' | '\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick.
lib/matplotlib/tests/test_text.py
Outdated
@@ -30,7 +30,7 @@ def find_matplotlib_font(**kw): | |||
from matplotlib.font_manager import FontProperties, findfont | |||
warnings.filterwarnings( | |||
'ignore', | |||
('findfont: Font family \[u?\'Foo\'\] not found. Falling back to .'), | |||
r'findfont: Font family \[u?\'Foo\'\] not found. Falling back to .', |
There was a problem hiding this comment.
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?
Thanks @Carreau |
Thanks !
…On Wed, Feb 1, 2017 at 4:31 PM, Nelle Varoquaux ***@***.***> wrote:
Merged #7925 <#7925>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7925 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAUez9dEJtH0NYiDiahyH0-bRrjJIZd8ks5rYSP1gaJpZM4Lqj9->
.
|
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