Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linters sometimes run before formatter #17366

Closed
DetachHead opened this issue Sep 10, 2021 · 2 comments
Closed

linters sometimes run before formatter #17366

DetachHead opened this issue Sep 10, 2021 · 2 comments
Assignees
Labels
area-formatting area-linting bug Issue identified by VS Code Team member as probable bug

Comments

@DetachHead
Copy link

DetachHead commented Sep 10, 2021

Environment data

  • VS Code version: 1.60
  • Extension version (available under the Extensions sidebar): v2021.9.1218897484
  • OS and version: windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9
  • Type of virtual environment used: venv
  • Relevant/affected Python packages and their versions: black 21.8b0, flake8 3.9.2
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: default

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

black formats the file, then flake8 runs on the formatted code, so no formatting errors appear

Actual behaviour

formatter runs, then formatting errors from flake8 appears on the newly formatted code where the errors are no longer there
linting and formatting

Steps to reproduce:

note that i can't reliably reproduce this, but if you change autosave to afterDelay it seems to happen much more often

  1. change some code to formatting that black won't like (but still valid syntax)
  2. ctrl+s
  3. wait for the formatter and linter(s) to run

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
##########Linting Output - mypy##########
Sandpit\foo.py:1:17: error: Incompatible types in assignment (expression has type "int", variable has type "str")  [assignment]
Found 1 error in 1 file (checked 1 source file)
> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
##########Linting Output - pylint##########
##########Linting Output - flake8##########
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m black --diff --quiet c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m black --diff --quiet c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
##########Linting Output - flake8##########
1,5,E,E241:multiple spaces after ':'
1,23,W,W292:no newline at end of file
1     E241 multiple spaces after ':'
1     W292 no newline at end of file
> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
##########Linting Output - mypy##########
##########Linting Output - pylint##########
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m mypy --show-column-numbers c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
> c:\Users\user\project\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\user\project\Sandpit\foo.py
cwd: c:\Users\user\project
##########Linting Output - mypy##########
Success: no issues found in 1 source file
##########Linting Output - flake8##########
##########Linting Output - pylint##########

--------------------------------------------------------------------

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

@DetachHead DetachHead added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Sep 10, 2021
@karthiknadig karthiknadig self-assigned this Sep 13, 2021
@karthiknadig karthiknadig added area-formatting area-linting triage and removed triage-needed Needs assignment to the proper sub-team labels Sep 13, 2021
@karthiknadig
Copy link
Member

related #408

@karthiknadig
Copy link
Member

We are currently investigating getting linters to work "on change". See #17235 , which should address this problem. So closing this in favor of addressing #408 and #17235

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting area-linting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants