vim-pyautoimport

automatically creating missing python imports
git clone https://git.ce9e.org/vim-pyautoimport.git

commit
912ee094cd4853d01ce0260ee8749ecfc7af534c
parent
92956e19d5331f6171525c9f20a28bb0368e5b4b
Author
Tobias Bengfort <bengfort@mpib-berlin.mpg.de>
Date
2022-01-31 13:33
import pyflakes late to avoid error on startup

Diffstat

M plugin/pyautoimport.py 7 ++++---

1 files changed, 4 insertions, 3 deletions


diff --git a/plugin/pyautoimport.py b/plugin/pyautoimport.py

@@ -2,20 +2,21 @@ import sys
    2     2 import subprocess
    3     3 from collections import Counter
    4     4 
    5    -1 from pyflakes.api import checkPath
    6    -1 from pyflakes.messages import UndefinedName
    7    -1 
    8     5 
    9     6 class Reporter:
   10     7     def __init__(self):
   11     8         self.names = set()
   12     9 
   13    10     def flake(self, msg):
   -1    11         from pyflakes.messages import UndefinedName
   -1    12 
   14    13         if isinstance(msg, UndefinedName):
   15    14             self.names.add(msg.message_args[0])
   16    15 
   17    16 
   18    17 def get_undefined_names(path):
   -1    18     from pyflakes.api import checkPath
   -1    19 
   19    20     reporter = Reporter()
   20    21     checkPath(path, reporter)
   21    22     return reporter.names