Open johndoknjas opened 1 week ago
Could you please share a copy/pastable example that I can use to repro with?
@alexr00 Sure, here it is:
import sys
from typing import Optional
from copy import copy
def first(args: Optional[list[str]]) -> None:
args = copy(sys.argv)
print(sys.argv if args is None else args)
def second(args: Optional[list[str]]) -> None:
print(sys.argv if sys.argv is None else args)
Thanks! I can't repro without the python extension. Moving to the appropriate repo.
Does this issue occur when all extensions are disabled?: Yes/No
Steps to Reproduce:
In the code below, the
argv
insys.argv
isn't highlighted in the first function. This seems to be because vscode infers that the condition (if args is None
) should never be true, due to the previous line. I'm not sure if this is intended behaviour though, because in the second function,sys.argv
is highlighted, despite it being more obvious that the condition should never be true.