bpo-38681: Enhance 2to3 conversion for blank line by samtatasurya · Pull Request #17096 · python/cpython · GitHub
Skip to content

bpo-38681: Enhance 2to3 conversion for blank line - #17096

Closed
samtatasurya wants to merge 8 commits into
python:mainfrom
samtatasurya:fix-issue-38681
Closed

samtatasurya wants to merge 8 commits into
python:mainfrom
samtatasurya:fix-issue-38681

Conversation

@samtatasurya

@samtatasurya samtatasurya commented Nov 9, 2019

Copy link
Copy Markdown

Main changes

  1. Added a new helper function BlankLineOrPass, which replaces BlankLine in fix_future.py and fix_itertools_imports.py.
  2. Added optional keyword argument reformat to FixerTestCase.check function in test_fixers.py.

Example 1
Code to be converted:

try:
    from __future__ import with_statement
except ImportError:
    pass

Before enhancement:

 try:
-    from __future__ import with_statement
+    
 except ImportError:
     pass

After enhancement:

 try:
-    from __future__ import with_statement
+    pass
 except ImportError:
     pass

Example 2
Code to be converted:

if sys.version_info < (3, 0):
    from itertools import imap

Before enhancement:

 if sys.version_info < (3, 0):
-    from itertools import imap
+

After enhancement:

 if sys.version_info < (3, 0):
-    from itertools import imap
+    pass

https://bugs.python.org/issue38681

Samuel Tatasurya added 4 commits November 6, 2019 00:17
…d future and itertools_imports fixers to use BlankLineOrPass instead of BlankLine.
…d future and itertools_imports fixers to use BlankLineOrPass instead of BlankLine.
@the-knights-who-say-ni

Copy link
Copy Markdown

@isidentical isidentical 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.

Looks great

Comment thread Lib/lib2to3/fixer_util.py Outdated
Comment thread Misc/NEWS.d/next/Library/2019-11-09-06-16-24.bpo-38681.jJobMS.rst Outdated
@isidentical
isidentical requested a review from pablogsal March 8, 2020 05:37
@iritkatriel

iritkatriel commented Oct 20, 2021

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants