We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When currently applying pycharm on a Python 2.7-compatible codebase, a few of such cases pop up:
try: from collections.abc import Iterable except ImportError: - from collections import Iterable + from collections.abc import Iterable
It would be useful if pyupgrade could detect if the code in both the try and except end up identical, and if so, remove the block.
try
except
In that case, the diff should become:
-try: - from collections.abc import Iterable -except ImportError: - from collections import Iterable +from collections.abc import Iterable
The text was updated successfully, but these errors were encountered:
the correct way to write such a concept is with if sys.version_info < (...): which would be auto-rewritten. the try except pattern is error-prone
if sys.version_info < (...):
while this is fixable -- it's a bit of a garbage-in-garbage-out situation
Sorry, something went wrong.
Fully agreed it’s not a good pattern. Would still be nice to be able to fix it automatically though!
No branches or pull requests
When currently applying pycharm on a Python 2.7-compatible codebase, a few of such cases pop up:
It would be useful if pyupgrade could detect if the code in both the
try
andexcept
end up identical, and if so, remove the block.In that case, the diff should become:
The text was updated successfully, but these errors were encountered: