@@ -193,26 +193,25 @@ def pylsp_code_actions(
193193
194194 _context = converter .structure (context , CodeActionContext )
195195 diagnostics = _context .diagnostics
196- diagnostics_with_fixes = [d for d in diagnostics if d .data ]
197196
198197 code_actions = []
199198 has_organize_imports = False
200199
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 (
212213 create_fix_code_action (document , diagnostic , fix ),
213- create_disable_code_action (document , diagnostic ),
214- ]
215- )
214+ )
216215
217216 checks = run_ruff_check (workspace , document )
218217 checks_with_fixes = [c for c in checks if c .fix ]
@@ -222,8 +221,11 @@ def pylsp_code_actions(
222221 check = checks_organize_imports [0 ]
223222 fix = check .fix # type: ignore
224223 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+ ]
227229 )
228230
229231 if checks_with_fixes :
0 commit comments