@@ -50,6 +50,14 @@ def f():
5050 "Ruff: Fix All (safe fixes)" ,
5151]
5252
53+ codeactions_unfixable = [
54+ "Ruff (F401): Remove unused import: `os`" ,
55+ "Ruff (F401): Disable for this line" ,
56+ # "Ruff (F841): Remove assignment to unused variable `a` (unsafe)",
57+ "Ruff (F841): Disable for this line" ,
58+ "Ruff: Fix All (safe fixes)" ,
59+ ]
60+
5361codeactions_import = [
5462 "Ruff: Organize imports" ,
5563 "Ruff: Fix All (safe fixes)" ,
@@ -85,6 +93,24 @@ def test_ruff_code_actions(workspace):
8593 assert sorted (codeactions ) == sorted (action_titles )
8694
8795
96+ def test_ruff_code_actions_unfixable (workspace ):
97+ _ , doc = temp_document (codeaction_str , workspace )
98+
99+ workspace ._config .update (
100+ {"plugins" : {"ruff" : {"select" : ["F" ], "unfixable" : ["F841" ]}}}
101+ )
102+ diags = ruff_lint .pylsp_lint (workspace , doc )
103+ range_ = cattrs .unstructure (
104+ Range (start = Position (line = 0 , character = 0 ), end = Position (line = 0 , character = 0 ))
105+ )
106+ actions = ruff_lint .pylsp_code_actions (
107+ workspace ._config , workspace , doc , range = range_ , context = {"diagnostics" : diags }
108+ )
109+ actions = converter .structure (actions , List [CodeAction ])
110+ action_titles = list (map (lambda action : action .title , actions ))
111+ assert sorted (codeactions_unfixable ) == sorted (action_titles )
112+
113+
88114def test_import_action (workspace ):
89115 workspace ._config .update (
90116 {
0 commit comments