microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
911 stars 131 forks source link

SyntaxError: iterable unpacking cannot be used in comprehension #2014

Open JacksonKearl opened 4 years ago

JacksonKearl commented 4 years ago

Environment data

Expected behaviour

def foo():
    return ["bar", "baz"]

print([*foo() for _ in range(10)])

I would expect a red squiggle and syntax error to appear here, given at runtime it throws:

SyntaxError: iterable unpacking cannot be used in comprehension

Actual behaviour

image

karthiknadig commented 4 years ago

You will need a linter to catch these: image

JacksonKearl commented 4 years ago

Many of the builtin linters don't flag this (bandit, pycodestyle, pydocstyle). And I don't think users (many of whom may be just starting out with python and not even know what a linter is) should need to install additional tooling to protect against basic syntax errors.

And in my case I am using flake8 but for whatever reason it didn't flag it either: image

Which means I had a very long running job fail at the last minute due to a syntax error.

JacksonKearl commented 4 years ago

I now appear to be in a state where I have linting enabled in .vscode/settings.json, but when I run 'Python : Run Linting' nothing at all happens and there is nothing written to the python output channel. When I run 'Python: Enable Linting', it shows 'off' and even when I select 'on' and enter the quick pick again it remains 'off'