diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index 2002a1ca..6f42ddcd 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -207,6 +207,7 @@ def _iter_modules(paths, prefix=''): yield importer, prefix + modname, ispkg # END COPY + iter_modules = _iter_modules if py_version >= 34 else pkgutil.iter_modules @@ -252,6 +253,7 @@ Usage:: """ + class Python3Method(object): def __init__(self, func): self.func = func @@ -312,10 +314,10 @@ def force_unicode(obj): try: import builtins # module name in python 3 except ImportError: - import __builtin__ as builtins + import __builtin__ as builtins # noqa: F401 -import ast +import ast # noqa: F401 def literal_eval(string): @@ -325,7 +327,7 @@ def literal_eval(string): try: from itertools import zip_longest except ImportError: - from itertools import izip_longest as zip_longest # Python 2 + from itertools import izip_longest as zip_longest # Python 2 # noqa: F401 try: FileNotFoundError = FileNotFoundError @@ -378,7 +380,7 @@ def utf8_repr(func): if is_py3: import queue else: - import Queue as queue + import Queue as queue # noqa: F401 try: # Attempt to load the C implementation of pickle on Python 2 as it is way @@ -544,7 +546,7 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None): if sys.platform == "win32": # The current directory takes precedence on Windows. - if not os.curdir in path: + if os.curdir not in path: path.insert(0, os.curdir) # PATHEXT is necessary to check on Windows. @@ -565,7 +567,7 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None): seen = set() for dir in path: normdir = os.path.normcase(dir) - if not normdir in seen: + if normdir not in seen: seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) diff --git a/jedi/debug.py b/jedi/debug.py index a4fd8646..49fda4bc 100644 --- a/jedi/debug.py +++ b/jedi/debug.py @@ -2,16 +2,17 @@ from jedi._compatibility import encoding, is_py3, u import os import time +_inited = False + + def _lazy_colorama_init(): """ - Lazily init colorama if necessary, not to screw up stdout is debug not - enabled. + Lazily init colorama if necessary, not to screw up stdout if debugging is + not enabled. This version of the function does nothing. """ - pass -_inited=False try: if os.name == 'nt': @@ -21,7 +22,8 @@ try: # Use colorama for nicer console output. from colorama import Fore, init from colorama import initialise - def _lazy_colorama_init(): + + def _lazy_colorama_init(): # noqa: F811 """ Lazily init colorama if necessary, not to screw up stdout is debug not enabled. diff --git a/jedi/utils.py b/jedi/utils.py index 1338d1b3..04e87c30 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -113,7 +113,7 @@ def setup_readline(namespace_module=__main__): # this code. This didn't use to be an issue until 3.3. Starting with # 3.4 this is different, it always overwrites the completer if it's not # already imported here. - import rlcompleter + import rlcompleter # noqa: F401 import readline except ImportError: print("Jedi: Module readline not available.") diff --git a/setup.cfg b/setup.cfg index f312e562..96111b23 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,6 @@ universal=1 [flake8] max-line-length = 100 +ignore = + # do not use bare 'except' + E722,