Skip to content

Commit 6256966

Browse files
committed
Fixing some pylint warnings
1 parent c24bbfa commit 6256966

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Diff for: pylsp/plugins/flake8_lint.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ def run_flake8(flake8_executable, args, document):
8181
try:
8282
cmd = [flake8_executable]
8383
cmd.extend(args)
84-
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
84+
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
8585
except IOError:
8686
log.debug("Can't execute %s. Trying with '%s -m flake8'", flake8_executable, sys.executable)
8787
cmd = [sys.executable, '-m', 'flake8']
8888
cmd.extend(args)
8989
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
90-
(stdout, stderr) = p.communicate(document.source.encode())
90+
with p as p:
91+
(stdout, stderr) = p.communicate(document.source.encode())
9192
if stderr:
9293
log.error("Error while running flake8 '%s'", stderr.decode())
9394
return stdout.decode()

Diff for: pylsp/plugins/pylint_lint.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,15 @@ def _run_pylint_stdio(pylint_executable, document, flags):
236236
cmd = [pylint_executable]
237237
cmd.extend(flags)
238238
cmd.extend(['--from-stdin', document.path])
239-
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
239+
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
240240
except IOError:
241241
log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable)
242242
cmd = ['python', '-m', 'pylint']
243243
cmd.extend(flags)
244244
cmd.extend(['--from-stdin', document.path])
245245
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
246-
(stdout, stderr) = p.communicate(document.source.encode())
246+
with p as p:
247+
(stdout, stderr) = p.communicate(document.source.encode())
247248
if stderr:
248249
log.error("Error while running pylint '%s'", stderr.decode())
249250
return stdout.decode()

0 commit comments

Comments
 (0)