@@ -193,26 +193,25 @@ def pylsp_code_actions(
193
193
194
194
_context = converter .structure (context , CodeActionContext )
195
195
diagnostics = _context .diagnostics
196
- diagnostics_with_fixes = [d for d in diagnostics if d .data ]
197
196
198
197
code_actions = []
199
198
has_organize_imports = False
200
199
201
- for diagnostic in diagnostics_with_fixes :
202
- fix = converter .structure (diagnostic .data , RuffFix )
203
-
204
- if diagnostic .code == "I001" :
205
- code_actions .append (
206
- create_organize_imports_code_action (document , diagnostic , fix )
207
- )
208
- has_organize_imports = True
209
- else :
210
- code_actions .extend (
211
- [
200
+ for diagnostic in diagnostics :
201
+ code_actions .append (create_disable_code_action (document , diagnostic ))
202
+
203
+ if diagnostic .data : # Has fix
204
+ fix = converter .structure (diagnostic .data , RuffFix )
205
+
206
+ if diagnostic .code == "I001" :
207
+ code_actions .append (
208
+ create_organize_imports_code_action (document , diagnostic , fix )
209
+ )
210
+ has_organize_imports = True
211
+ else :
212
+ code_actions .append (
212
213
create_fix_code_action (document , diagnostic , fix ),
213
- create_disable_code_action (document , diagnostic ),
214
- ]
215
- )
214
+ )
216
215
217
216
checks = run_ruff_check (workspace , document )
218
217
checks_with_fixes = [c for c in checks if c .fix ]
@@ -222,8 +221,11 @@ def pylsp_code_actions(
222
221
check = checks_organize_imports [0 ]
223
222
fix = check .fix # type: ignore
224
223
diagnostic = create_diagnostic (check )
225
- code_actions .append (
226
- create_organize_imports_code_action (document , diagnostic , fix ),
224
+ code_actions .extend (
225
+ [
226
+ create_organize_imports_code_action (document , diagnostic , fix ),
227
+ create_disable_code_action (document , diagnostic ),
228
+ ]
227
229
)
228
230
229
231
if checks_with_fixes :
0 commit comments