@@ -181,6 +181,19 @@ def pylsp_lint(
181
181
182
182
didSettingsChange (workspace .root_path , settings )
183
183
184
+ # Running mypy with a single file (document) ignores any exclude pattern
185
+ # configured with mypy. We can now add our own exclude section like so:
186
+ # [tool.pylsp-mypy]
187
+ # exclude = ["tests/*"]
188
+ exclude = settings .get ("exclude" , [])
189
+ for pattern in exclude :
190
+ if re .match (pattern , document .path ):
191
+ log .debug (
192
+ f"Not running because { document .path } matches "
193
+ f"exclude pattern '{ pattern } '"
194
+ )
195
+ return []
196
+
184
197
if settings .get ("report_progress" , False ):
185
198
with workspace .report_progress ("lint: mypy" ):
186
199
return get_diagnostics (workspace , document , settings , is_saved )
@@ -218,15 +231,6 @@ def get_diagnostics(
218
231
document .path ,
219
232
is_saved ,
220
233
)
221
- exclude = settings .get ("exclude" , [])
222
- for pattern in exclude :
223
- if re .match (pattern , document .path ):
224
- log .debug (
225
- "Not running because %s matches exclude pattern %s" ,
226
- document .path ,
227
- settings .get ("exclude" ),
228
- )
229
- return []
230
234
231
235
live_mode = settings .get ("live_mode" , True )
232
236
dmypy = settings .get ("dmypy" , False )
0 commit comments