Skip to content

Commit

Permalink
Skip running organize import on interactive window (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Nov 11, 2022
1 parent 570af74 commit 29c3d72
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bundled/tool/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ def is_python(code: str) -> bool:
return True


def is_interactive(file_path: str) -> bool:
"""Checks if the file path represents interactive window."""
return file_path.endswith(".interactive")


def _formatting_helper(document: workspace.Document) -> list[lsp.TextEdit] | None:
result = _run_tool_on_document(document, use_stdin=True)
if result.stdout:
Expand Down Expand Up @@ -529,6 +534,10 @@ def _run_tool_on_document(
log_warning(f"Skipping standard library file: {document.path}")
return None

if is_interactive(document.path):
log_warning(f"Skipping interactive window: {document.path}")
return None

if not is_python(document.source):
log_warning(f"Skipping non python code: {document.path}")
return None
Expand Down

0 comments on commit 29c3d72

Please sign in to comment.