diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py index d6323950..03504ef4 100644 --- a/pylsp/plugins/flake8_lint.py +++ b/pylsp/plugins/flake8_lint.py @@ -68,12 +68,12 @@ def run_flake8(flake8_executable, args, document): try: cmd = [flake8_executable] cmd.extend(args) - p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with except IOError: log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable) cmd = ['python', '-m', 'flake8'] cmd.extend(args) - p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with (stdout, stderr) = p.communicate(document.source.encode()) if stderr: log.error("Error while running flake8 '%s'", stderr.decode()) diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py index 54917875..d5ff3dbf 100644 --- a/pylsp/plugins/pylint_lint.py +++ b/pylsp/plugins/pylint_lint.py @@ -236,13 +236,13 @@ def _run_pylint_stdio(pylint_executable, document, flags): cmd = [pylint_executable] cmd.extend(flags) cmd.extend(['--from-stdin', document.path]) - p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with except IOError: log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable) cmd = ['python', '-m', 'pylint'] cmd.extend(flags) cmd.extend(['--from-stdin', document.path]) - p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with (stdout, stderr) = p.communicate(document.source.encode()) if stderr: log.error("Error while running pylint '%s'", stderr.decode()) diff --git a/test/plugins/test_flake8_lint.py b/test/plugins/test_flake8_lint.py index eaabd403..4faf0dda 100644 --- a/test/plugins/test_flake8_lint.py +++ b/test/plugins/test_flake8_lint.py @@ -21,10 +21,9 @@ def using_const(): def temp_document(doc_text, workspace): - temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False) - name = temp_file.name - temp_file.write(doc_text) - temp_file.close() + with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file: + name = temp_file.name + temp_file.write(doc_text) doc = Document(uris.from_fs_path(name), workspace) return name, doc diff --git a/test/plugins/test_pylint_lint.py b/test/plugins/test_pylint_lint.py index f83e7542..cf7a7e44 100644 --- a/test/plugins/test_pylint_lint.py +++ b/test/plugins/test_pylint_lint.py @@ -28,10 +28,9 @@ def hello(): @contextlib.contextmanager def temp_document(doc_text, workspace): try: - temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False) - name = temp_file.name - temp_file.write(doc_text) - temp_file.close() + with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file: + name = temp_file.name + temp_file.write(doc_text) yield Document(uris.from_fs_path(name), workspace) finally: os.remove(name)