@@ -109,12 +109,13 @@ def run_flake8(flake8_executable, args, document):
109
109
)
110
110
111
111
log .debug ("Calling %s with args: '%s'" , flake8_executable , args )
112
+ popen_kwargs = {}
113
+ if cwd := document ._workspace .root_path :
114
+ popen_kwargs ["cwd" ] = cwd
112
115
try :
113
116
cmd = [flake8_executable ]
114
117
cmd .extend (args )
115
- p = Popen (
116
- cmd , stdin = PIPE , stdout = PIPE , stderr = PIPE , cwd = document ._workspace .root_path
117
- )
118
+ p = Popen (cmd , stdin = PIPE , stdout = PIPE , stderr = PIPE , ** popen_kwargs )
118
119
except IOError :
119
120
log .debug (
120
121
"Can't execute %s. Trying with '%s -m flake8'" ,
@@ -124,7 +125,7 @@ def run_flake8(flake8_executable, args, document):
124
125
cmd = [sys .executable , "-m" , "flake8" ]
125
126
cmd .extend (args )
126
127
p = Popen ( # pylint: disable=consider-using-with
127
- cmd , stdin = PIPE , stdout = PIPE , stderr = PIPE , cwd = document . _workspace . root_path
128
+ cmd , stdin = PIPE , stdout = PIPE , stderr = PIPE , ** popen_kwargs
128
129
)
129
130
(stdout , stderr ) = p .communicate (document .source .encode ())
130
131
if stderr :
0 commit comments