-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from brettcannon/fix_long_call
Fix references to 'long'
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import absolute_import | ||
|
||
from lib2to3 import fixer_base | ||
from lib2to3 import fixer_util | ||
|
||
|
||
class FixIntLongTuple(fixer_base.BaseFix): | ||
|
||
run_order = 4 # Must run before fix_long. | ||
|
||
PATTERN = """ | ||
pair=atom < '(' testlist_gexp < ( | ||
('int' ',' 'long') | | ||
('long' ',' 'int') | ||
) > ')' > | ||
""" | ||
|
||
def transform(self, node, results): | ||
if 'name' in results: | ||
name = results['name'] | ||
name.replace(fixer_util.Name('int', prefix=name.prefix)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
takluyver
Author
Contributor
|
||
else: | ||
fixer_util.touch_import(None, 'six', node) | ||
pair = results['pair'] | ||
pair.replace(fixer_util.Name('six.integer_types', prefix=pair.prefix)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import absolute_import | ||
|
||
from utils import check_on_input | ||
|
||
|
||
INT_LONG_ISINSTANCE = ("""\ | ||
isinstance(1, (int, long)) | ||
""", """\ | ||
import six | ||
isinstance(1, six.integer_types) | ||
""") | ||
|
||
LONG_INT_ISINSTANCE = ("""\ | ||
isinstance(1, (long, int)) | ||
""", """\ | ||
import six | ||
isinstance(1, six.integer_types) | ||
""") | ||
|
||
|
||
def test_int_long_isinstance(): | ||
check_on_input(*INT_LONG_ISINSTANCE) | ||
|
||
def test_long_int_isinstance(): | ||
check_on_input(*LONG_INT_ISINSTANCE) |
This branch isn't covered by tests (https://coveralls.io/files/301713367). What is it for? The pattern seems to only match a pair.