[[nbpython-commits]] [hg] main/contrib: 156442: Python __future__ imports not sorted ...

  • From: Tor Norbye < >
  • To:
  • Subject: [[nbpython-commits]] [hg] main/contrib: 156442: Python __future__ imports not sorted ...
  • Date: Thu, 21 Oct 2010 08:34:31 -0700

changeset 7e48e1ab8711 in main/contrib
details: http://hg.netbeans.org/main/contrib?cmd=changeset;node=7e48e1ab8711
description:
        156442: Python __future__ imports not sorted properly

diffstat:

 
python.editor/src/org/netbeans/modules/python/editor/imports/ImportEntry.java 
           |  5 +++++
 python.editor/test/unit/data/testfiles/imports/futures.py                    
            |  8 ++++++++
 
python.editor/test/unit/data/testfiles/imports/futures.py.testSortFutureImports.imported
 |  8 ++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)

diffs (41 lines):

diff --git 
a/python.editor/src/org/netbeans/modules/python/editor/imports/ImportEntry.java
 
b/python.editor/src/org/netbeans/modules/python/editor/imports/ImportEntry.java
--- 
a/python.editor/src/org/netbeans/modules/python/editor/imports/ImportEntry.java
+++ 
b/python.editor/src/org/netbeans/modules/python/editor/imports/ImportEntry.java
@@ -120,6 +120,11 @@
     }
 
     public int compareTo(ImportEntry other) {
+        boolean thisIsFuture = "__future__".equals(module); // NOI18N
+        boolean otherIsFuture = "__future__".equals(other.module); // NOI18N
+        if (thisIsFuture != otherIsFuture) {
+            return thisIsFuture ? -1 : 1;
+        }
         if (isSystem != other.isSystem) {
             return isSystem ? -1 : 1;
         }
diff --git a/python.editor/test/unit/data/testfiles/imports/futures.py 
b/python.editor/test/unit/data/testfiles/imports/futures.py
new file mode 100644
--- /dev/null
+++ b/python.editor/test/unit/data/testfiles/imports/futures.py
@@ -0,0 +1,8 @@
+# Ensure that the future imports here aren't shown as unused or imported 
symbols for code completion
+import ghi
+from abc import whatever
+from __future__ import with_statement, absolute_imports
+from __future__ import with_statement
+from def import whatever
+import jkl
+
diff --git 
a/python.editor/test/unit/data/testfiles/imports/futures.py.testSortFutureImports.imported
 
b/python.editor/test/unit/data/testfiles/imports/futures.py.testSortFutureImports.imported
new file mode 100644
--- /dev/null
+++ 
b/python.editor/test/unit/data/testfiles/imports/futures.py.testSortFutureImports.imported
@@ -0,0 +1,8 @@
+# Ensure that the future imports here aren't shown as unused or imported 
symbols for code completion
+from __future__ import absolute_imports
+from __future__ import with_statement
+import ghi
+from abc import whatever
+from def import whatever
+import jkl
+

[[nbpython-commits]] [hg] main/contrib: 156442: Python __future__ imports not sorted ...

Tor Norbye 10/21/2010

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close