@@ -61,17 +61,22 @@ def __init__(self, parent):
61
61
'flake8' ,
62
62
button_group = linting_bg
63
63
)
64
-
64
+ ruff_linting_radio = self .create_radiobutton (
65
+ _ ("Ruff (Advanced)" ),
66
+ 'ruff' ,
67
+ button_group = linting_bg
68
+ )
65
69
disable_linting_radio = self .create_radiobutton (
66
70
_ ("Disable linting" ),
67
71
'no_linting' ,
68
72
button_group = linting_bg
69
73
)
70
-
74
+
71
75
linting_select_layout = QVBoxLayout ()
72
76
linting_select_layout .addSpacing (3 * AppStyle .MarginSize )
73
77
linting_select_layout .addWidget (basic_linting_radio )
74
78
linting_select_layout .addWidget (flake_linting_radio )
79
+ linting_select_layout .addWidget (ruff_linting_radio )
75
80
linting_select_layout .addWidget (disable_linting_radio )
76
81
linting_select_group .setLayout (linting_select_layout )
77
82
@@ -89,6 +94,43 @@ def __init__(self, parent):
89
94
configuration_options_group = QGroupBox (_ ("Provider options" ))
90
95
configuration_options_layout = QVBoxLayout ()
91
96
97
+ # ruff options
98
+ self .ruff_exclude = self .create_lineedit (
99
+ _ ("Exclude these files or directories:" ),
100
+ 'ruff/exclude' ,
101
+ alignment = Qt .Horizontal ,
102
+ word_wrap = False ,
103
+ placeholder = _ ("Exclude test files: (?!test_).*\\ .py" ),
104
+ )
105
+
106
+ ruff_select = self .create_lineedit (
107
+ _ ("Show these errors or warnings:" ),
108
+ 'ruff/extendSelect' ,
109
+ alignment = Qt .Horizontal ,
110
+ word_wrap = False ,
111
+ placeholder = _ ("Example codes: E113, W391" ),
112
+ )
113
+
114
+ ruff_ignore = self .create_lineedit (
115
+ _ ("Ignore these errors or warnings:" ),
116
+ 'ruff/extendIgnore' ,
117
+ alignment = Qt .Horizontal ,
118
+ word_wrap = False ,
119
+ placeholder = _ ("Default is: E" ),
120
+ )
121
+
122
+ ruff_layout = QGridLayout ()
123
+ ruff_layout .addWidget (self .ruff_exclude .label , 1 , 0 )
124
+ ruff_layout .addWidget (self .ruff_exclude .textbox , 1 , 1 )
125
+ ruff_layout .addWidget (ruff_select .label , 2 , 0 )
126
+ ruff_layout .addWidget (ruff_select .textbox , 2 , 1 )
127
+ ruff_layout .addWidget (ruff_ignore .label , 3 , 0 )
128
+ ruff_layout .addWidget (ruff_ignore .textbox , 3 , 1 )
129
+
130
+ ruff_grid_widget = QWidget ()
131
+ ruff_grid_widget .setLayout (ruff_layout )
132
+
133
+ # Flake8 options
92
134
self .flake8_filenames_match = self .create_lineedit (
93
135
_ ("Only check these filenames:" ),
94
136
'flake8/filename' ,
@@ -130,38 +172,53 @@ def __init__(self, parent):
130
172
flake8_layout .addWidget (flake8_select .textbox , 3 , 1 )
131
173
flake8_layout .addWidget (flake8_ignore .label , 4 , 0 )
132
174
flake8_layout .addWidget (flake8_ignore .textbox , 4 , 1 )
175
+ flake8_grid_widget = QWidget ()
176
+ flake8_grid_widget .setLayout (flake8_layout )
133
177
178
+ # pyflakes options
134
179
pyflakes_conf_options = QLabel (
135
180
_ ("There are no configuration options for Pyflakes" )
136
181
)
137
- not_select_conf_options = QLabel (_ ("Linting is disabled" ))
138
182
139
- grid_widget = QWidget ()
140
- grid_widget . setLayout ( flake8_layout )
183
+ # Disabled linting options
184
+ not_select_conf_options = QLabel ( _ ( "Linting is disabled" ) )
141
185
142
- configuration_options_layout .addWidget (grid_widget )
186
+ configuration_options_layout .addWidget (ruff_grid_widget )
187
+ configuration_options_layout .addWidget (flake8_grid_widget )
143
188
configuration_options_layout .addWidget (pyflakes_conf_options )
144
189
configuration_options_layout .addWidget (not_select_conf_options )
145
190
191
+ ruff_linting_radio .radiobutton .toggled .connect (
192
+ lambda checked : (
193
+ ruff_grid_widget .setVisible (checked ),
194
+ flake8_grid_widget .setVisible (False ),
195
+ pyflakes_conf_options .setVisible (False ),
196
+ not_select_conf_options .setVisible (False )
197
+ ) if checked else None
198
+ )
199
+
146
200
flake_linting_radio .radiobutton .toggled .connect (
147
201
lambda checked : (
148
- grid_widget .setVisible (checked ),
149
- pyflakes_conf_options .setVisible (not checked ),
202
+ ruff_grid_widget .setVisible (False ),
203
+ flake8_grid_widget .setVisible (checked ),
204
+ pyflakes_conf_options .setVisible (False ),
150
205
not_select_conf_options .setVisible (False )
151
206
) if checked else None
152
207
)
153
208
154
209
basic_linting_radio .radiobutton .toggled .connect (
155
210
lambda checked : (
156
- grid_widget .setVisible (False ),
211
+ ruff_grid_widget .setVisible (False ),
212
+ flake8_grid_widget .setVisible (False ),
157
213
pyflakes_conf_options .setVisible (checked ),
158
214
not_select_conf_options .setVisible (False )
159
215
) if checked else None
160
216
)
161
217
162
218
disable_linting_radio .radiobutton .toggled .connect (
163
219
lambda checked : (
164
- grid_widget .setVisible (False ),
220
+ ruff_grid_widget .setVisible (False ),
221
+ flake8_grid_widget .setVisible (False ),
165
222
pyflakes_conf_options .setVisible (False ),
166
223
not_select_conf_options .setVisible (checked )
167
224
) if checked else None
@@ -207,9 +264,16 @@ def is_valid(self):
207
264
return False
208
265
209
266
try :
267
+ # flake8 check
210
268
flake8_excludes = self .flake8_exclude .textbox .text ().split ("," )
211
269
for match in flake8_excludes :
212
270
re .compile (match .strip ())
271
+
272
+ # ruff check
273
+ ruff_excludes = self .ruff_exclude .textbox .text ().split ("," )
274
+ for match in ruff_excludes :
275
+ re .compile (match .strip ())
276
+
213
277
except re .error :
214
278
self .report_invalid_regex (files = False )
215
279
return False
0 commit comments