@@ -97,11 +97,14 @@ def parse_line(line: str, document: Optional[Document] = None) -> Optional[Dict[
9797
9898def apply_overrides (args : List [str ], overrides : List [Any ]) -> List [str ]:
9999 """Replace or combine default command-line options with overrides."""
100- o = iter (overrides )
101- if True not in o :
100+ overrides_iterator = iter (overrides )
101+ if True not in overrides_iterator :
102102 return overrides
103- rest = list (o )
104- return [* overrides [: - (len (rest ) + 1 )], * args , * rest ]
103+ # If True is in the list, the if above leaves the iterator at the element after True,
104+ # therefore, the list below only contains the elements after the True
105+ rest = list (overrides_iterator )
106+ # slice of the True and the rest, add the args, add the rest
107+ return overrides [: - (len (rest ) + 1 )] + args + rest
105108
106109
107110@hookimpl
@@ -195,12 +198,11 @@ def pylsp_lint(
195198 if settings .get ("strict" , False ):
196199 args .append ("--strict" )
197200
198- overrides = settings .get ("overrides" )
201+ overrides = settings .get ("overrides" , [ True ] )
199202
200203 if not dmypy :
201204 args .extend (["--incremental" , "--follow-imports" , "silent" ])
202- if overrides :
203- args = apply_overrides (args , overrides )
205+ args = apply_overrides (args , overrides )
204206
205207 log .info ("executing mypy args = %s" , args )
206208 completed_process = subprocess .run (
@@ -214,15 +216,17 @@ def pylsp_lint(
214216 # If daemon is hung, kill will reset
215217 # If daemon is dead/absent, kill will no-op.
216218 # In either case, reset to fresh state
217- completed_process = subprocess .run (["dmypy" , * args ], stderr = subprocess .PIPE )
219+ completed_process = subprocess .run (
220+ ["dmypy" , * apply_overrides (args , overrides )], stderr = subprocess .PIPE
221+ )
218222 _err = completed_process .stderr .decode ()
219223 _status = completed_process .returncode
220224 if _status != 0 :
221225 log .info ("restarting dmypy from status: %s message: %s" , _status , _err .strip ())
222226 subprocess .run (["dmypy" , "kill" ])
223227
224228 # run to use existing daemon or restart if required
225- args = ["run" , "--" ] + ( apply_overrides (args , overrides ) if overrides else args )
229+ args = ["run" , "--" ] + apply_overrides (args , overrides )
226230 log .info ("dmypy run args = %s" , args )
227231 completed_process = subprocess .run (
228232 ["dmypy" , * args ], stdout = subprocess .PIPE , stderr = subprocess .PIPE
0 commit comments