Skip to content

Commit 5bd1a3b

Browse files
committed
closes #8
1 parent bb875df commit 5bd1a3b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pylsp_mypy/plugin.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)