File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
jupyterlab_code_formatter Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -474,6 +474,18 @@ def format_code(
474
474
return process .stdout
475
475
476
476
477
+ class RuffFixFormatter (CommandLineFormatter ):
478
+
479
+ def __init__ (self ):
480
+ try :
481
+ from ruff .__main__ import find_ruff_bin
482
+
483
+ ruff_command = find_ruff_bin ()
484
+ except (ImportError , FileNotFoundError ):
485
+ ruff_command = "ruff"
486
+ self .command = [ruff_command , "check" , "--fix-only" , "-" ]
487
+
488
+
477
489
SERVER_FORMATTERS = {
478
490
"black" : BlackFormatter (),
479
491
"blue" : BlueFormatter (),
@@ -485,4 +497,5 @@ def format_code(
485
497
"scalafmt" : CommandLineFormatter (command = ["scalafmt" , "--stdin" ]),
486
498
"rustfmt" : CommandLineFormatter (command = ["rustfmt" ]),
487
499
"astyle" : CommandLineFormatter (command = ["astyle" ]),
500
+ "ruff" : RuffFixFormatter (),
488
501
}
Original file line number Diff line number Diff line change 296
296
"additionalProperties" : false ,
297
297
"type" : " object"
298
298
},
299
+ "ruff" : {
300
+ "properties" :{
301
+ "args" : {"type" : " array" , "items" : {"type" : " string" }}
302
+ },
303
+ "additionalProperties" : false ,
304
+ "type" : " object"
305
+ },
299
306
"formatOnSave" : {
300
307
"additionalProperties" : false ,
301
308
"type" : " boolean"
395
402
"args" : []
396
403
}
397
404
},
405
+ "ruff" : {
406
+ "title" : " Ruff Config" ,
407
+ "description" : " Command line options to be passed to ruff." ,
408
+ "$ref" : " #/definitions/ruff" ,
409
+ "default" : {
410
+ "args" : [" --select=I001" ]
411
+ }
412
+ },
398
413
"suppressFormatterErrors" : {
399
414
"title" : " Suppress formatter errors" ,
400
415
"description" : " Whether to suppress all errors reported by formatter while formatting. Useful when you have format on save mode on." ,
You can’t perform that action at this time.
0 commit comments