Skip to content

Commit

Permalink
feat: updated to *isort 5.9.3* API
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenxxiu committed Sep 28, 2021
1 parent e793117 commit 41993ae
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions isort_file.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import sys
from pathlib import Path

sys.path.append(os.path.dirname(__file__))
import isort
import sublime
import sublime_plugin

from .isort import SortImports

sys.path.append(os.path.dirname(__file__))

DEFAULT_SORT_ON_SAVE = True


Expand Down Expand Up @@ -36,11 +35,11 @@ def sort_imports(self, edit):

this_contents = self.get_buffer_contents()
settings = self.view.settings().get('isort') or {}
sorted_imports = SortImports(
file_path=self.view.file_name(), # to load isort settings
file_contents=this_contents,
sorted_imports = isort.code(
code=this_contents,
file_path=Path(self.view.file_name()), # to load isort settings
**settings
).output
)
self.view.replace(edit, self.get_region(), sorted_imports)

# Our sel has moved now..
Expand Down

0 comments on commit 41993ae

Please sign in to comment.