@@ -153,9 +153,12 @@ def pylsp_lint(
153153 args = ["--show-column-numbers" ]
154154
155155 global tmpFile
156- if live_mode and not is_saved and tmpFile :
157- log .info ("live_mode tmpFile = %s" , live_mode )
158- tmpFile = open (tmpFile .name , "w" )
156+ if live_mode and not is_saved :
157+ if tmpFile :
158+ tmpFile = open (tmpFile .name , "w" )
159+ else :
160+ tmpFile = tempfile .NamedTemporaryFile ("w" , delete = False )
161+ log .info ("live_mode tmpFile = %s" , tmpFile .name )
159162 tmpFile .write (document .source )
160163 tmpFile .close ()
161164 args .extend (["--shadow-file" , document .path , tmpFile .name ])
@@ -261,13 +264,6 @@ def init(workspace: str) -> Dict[str, str]:
261264 mypyConfigFile = findConfigFile (workspace , ["mypy.ini" , ".mypy.ini" ])
262265 mypyConfigFileMap [workspace ] = mypyConfigFile
263266
264- if ("enabled" not in configuration or configuration ["enabled" ]) and (
265- "live_mode" not in configuration or configuration ["live_mode" ]
266- ):
267- global tmpFile
268- tmpFile = tempfile .NamedTemporaryFile ("w" , delete = False )
269- tmpFile .close ()
270-
271267 log .info ("mypyConfigFile = %s configuration = %s" , mypyConfigFile , configuration )
272268 return configuration
273269
0 commit comments