Skip to content

Commit

Permalink
Start passing extra sorting options to ruff-api (#247)
Browse files Browse the repository at this point in the history
Depends on ruff-api v0.1.0. Fixes #246
  • Loading branch information
amyreese authored Oct 25, 2024
1 parent 3754b0b commit f5ff46e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ lsp = [
"pygls >= 1.3",
]
ruff = [
"ruff-api>=0.0.8",
"ruff-api>=0.1.0",
]
dev = [
"attribution==1.8.0",
Expand All @@ -44,7 +44,7 @@ dev = [
"flake8==7.1.1",
"mypy==1.11.2",
"pygls==1.3.1",
"ruff-api==0.0.8",
"ruff-api==0.1.0",
"usort==1.0.8.post1",
]
docs = [
Expand Down
6 changes: 6 additions & 0 deletions ufmt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def ufmt_bytes(
content = result.output
elif ufmt_config.sorter == Sorter.ruff_api:
ruff_isort_options = ruff_api.SortOptions(
# match µsort configuration
first_party_modules=[
imp
for imp, category in usort_config.known.items()
Expand All @@ -120,6 +121,11 @@ def ufmt_bytes(
for imp, category in usort_config.known.items()
if category == CAT_STANDARD_LIBRARY
],
detect_same_package=usort_config.first_party_detection,
# match µsort behavior for now
case_sensitive=False,
combine_as_imports=True,
order_by_type=False,
)
content_str = ruff_api.isort_string(
path.as_posix(),
Expand Down

0 comments on commit f5ff46e

Please sign in to comment.