File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change 19
19
"""
20
20
).strip ()
21
21
22
+ _UNUSED_IMPORTS = tw .dedent (
23
+ """
24
+ import unused_import
25
+ """
26
+ ).strip ()
27
+
22
28
_SORTED_IMPORTS = tw .dedent (
23
29
"""
24
30
import asyncio
30
36
31
37
_UNFORMATTED_CODE = tw .dedent (
32
38
"""
33
- def foo(): pass
34
- def bar(): pass
39
+ def foo(): return asyncio.subprocess.DEVNULL
40
+ def bar(): return x(io.DEFAULT_BUFFER_SIZE)
35
41
"""
36
42
).strip ()
37
43
38
44
_FORMATTED_CODE = tw .dedent (
39
45
"""
40
46
def foo():
41
- pass
47
+ return asyncio.subprocess.DEVNULL
42
48
43
49
44
50
def bar():
45
- pass
51
+ return x(io.DEFAULT_BUFFER_SIZE)
46
52
"""
47
53
).strip ()
48
54
@@ -121,3 +127,22 @@ def test_ruff_format_and_sort_imports(workspace):
121
127
)
122
128
got = run_plugin_format (workspace , doc )
123
129
assert want == got
130
+
131
+
132
+ def test_ruff_format_via_all (workspace ):
133
+ # If `pylsp.plugins.ruff.format` contains "ALL", formatting should apply
134
+ # the automatic fixes for unsorted-imports (I001) and unused-import (F401)
135
+ txt = f"{ _UNUSED_IMPORTS } \n { _UNSORTED_IMPORTS } \n { _UNFORMATTED_CODE } "
136
+ want = f"{ _SORTED_IMPORTS } \n \n \n { _FORMATTED_CODE } \n "
137
+ _ , doc = temp_document (txt , workspace )
138
+ workspace ._config .update (
139
+ {
140
+ "plugins" : {
141
+ "ruff" : {
142
+ "format" : ["ALL" ],
143
+ }
144
+ }
145
+ }
146
+ )
147
+ got = run_plugin_format (workspace , doc )
148
+ assert want == got
You can’t perform that action at this time.
0 commit comments