@@ -181,6 +181,18 @@ 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 " f"exclude pattern '{ pattern } '"
193
+ )
194
+ return []
195
+
184
196
if settings .get ("report_progress" , False ):
185
197
with workspace .report_progress ("lint: mypy" ):
186
198
return get_diagnostics (workspace , document , settings , is_saved )
@@ -218,15 +230,6 @@ def get_diagnostics(
218
230
document .path ,
219
231
is_saved ,
220
232
)
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
233
231
234
live_mode = settings .get ("live_mode" , True )
232
235
dmypy = settings .get ("dmypy" , False )
0 commit comments