You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat > test-future.py
x = str(3)
allowed_types = basestring, int
assert isinstance('', allowed_types)
$ futurize test-future.py -w
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored test-future.py
--- test-future.py (original)
+++ test-future.py (refactored)
@@ -1,3 +1,4 @@
+from builtins import str
x = str(3)
-allowed_types = basestring, int
+allowed_types = str, int
assert isinstance('', allowed_types)
RefactoringTool: Files that were modified:
RefactoringTool: test-future.py
$ python2.7 test-future.py
Traceback (most recent call last):
File "test-future.py", line 4, in <module>
assert isinstance('', allowed_types)
AssertionError
Here you see a simple example where a file that worked on Python 2 before futurize fails on Python 2 after futurize. Interestingly, it's the str(3) that triggers the import of str which breaks the type check.
Similarly, if the type being checked is unicode, futurize also breaks it:
Consider this failing example:
Here you see a simple example where a file that worked on Python 2 before futurize fails on Python 2 after futurize. Interestingly, it's the
str(3)
that triggers the import ofstr
which breaks the type check.Similarly, if the type being checked is unicode, futurize also breaks it:
The six project handles this by using a special variable
string_types
for doing type comparisons for strings.What is the solution for
future
?The text was updated successfully, but these errors were encountered: