-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use general OSError and more Python3 defaults from pyupgrade #19241
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
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.
Thanks for the PR, and welcome to Matplotlib!
Generally 👍 apart from the changes to versioneer.py
.
versioneer.py
Outdated
@@ -339,7 +339,6 @@ | |||
|
|||
""" | |||
|
|||
from __future__ import print_function |
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.
Please don't change anything in versioneer.py
. It's a vendored file from (https://github.com/python-versioneer/python-versioneer) with slight modifications. Additional local changes make it harder to pull in changes from the upstream version.
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.
Thank you @timhoffm . I have removed versioneer.py
from my PR entirely.
According to PEP 3151, OSError can be used for all system-related exceptions and thus replace IOError, EnvironmentError, socket.error, etc.
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.
All the raise OSError('
for missing files should probably be FileNotFoundError
instead.
@@ -71,7 +71,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): | |||
stderr=(subprocess.PIPE if hide_stderr | |||
else None)) | |||
break | |||
except EnvironmentError: | |||
except OSError: |
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 would not bother changing this file either as it will be deleted by #18971 .
PR Summary
Running
pyupgrade --py3-plus
and ignoring all string updates (percent/format/f) to use defaults introduced in Python3.PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).