Commits

jcristau committed 933e275

Fix false positive in reimport check (closes #60828)

  • Participants
  • Parent commits 34f18e2

Comments (0)

Files changed (4)

       this change may break it has now location gain a new item giving the
       column offset.
 
+    * #60828: Fix false positive in reimport check
+
 2011-01-11  --  0.23.0
     * documentation update, add manpages
 

checkers/imports.py

     """return the node where [base.]<name> is imported or None if not found
     """
     first = None
+    found = False
     for first in context.values():
         if isinstance(first, astng.Import):
             if name in [iname[0] for iname in first.names]:
+                found = True
                 break
         elif isinstance(first, astng.From):
             if base == first.modname and level == first.level and \
                    name in [iname[0] for iname in first.names]:
+                found = True
                 break
-    if first is not node and not are_exclusive(first, node):
+    if found and first is not node and not are_exclusive(first, node):
         return first
 
 # utilities to represents import dependencies as tree and dot graph ###########

test/input/func_w0404.py

+"""pylint ticket #60828"""
+
+__revision__ = 0
+
+def reimport():
+    """docstring"""
+    import os

test/messages/func_w0404.txt

+W:  7:reimport: Unused variable 'os'