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

Linting more than just my code in an infinite loop #18759

Closed
MatrixManAtYrService opened this issue Mar 22, 2022 · 18 comments
Closed

Linting more than just my code in an infinite loop #18759

MatrixManAtYrService opened this issue Mar 22, 2022 · 18 comments
Assignees
Labels
area-linting bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team

Comments

@MatrixManAtYrService
Copy link

Issue Type: Bug

Behaviour

Expected vs. Actual

If I'm not making any changes, I don't expect flake8 to run over and over. And usually, that's the case. But every now and then the processor shoots to 100

Screen Shot 2022-03-21 at 11 13 46 AM

and the "problems" indicator starts counting up from zero over and over again, whether or not I'm making any changes. Restarting VSCode fixes it for a little while

I know it's running linting because while it's happening 3-Python.log shows:

##########Linting Output - flake8##########
> ~/.pyenv/versions/3.10.0a6/bin/python ~/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/linter.py -p flake8 /usr/local/bin/flake8 --max-line-length=120 --ignore=E402,E302,E305,E266,W503,E127,E241,E128,E201,E203,E202,F811,E501 ~/.vscode/extensions/ms-python.vscode-pylance-2022.3.2/dist/typeshed-fallback/stdlib/pty.pyi
 ...
##########Linting Output - flake8##########
 ...
##########Linting Output - flake8##########
...

over and over. I'm not sure why this would show up in my Electron process though, so I'm thinking that whatever is stuck in an infinite loop, it includes more than just linting.

Steps to reproduce:

I don't know, it seems to happen randomly. Usually once per half-hour or so, but occasionally I'll get away with coding for days before it happens.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Pyenv
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: true
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: false
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.2.1924087327
VS Code version: Code 1.65.2 (Universal) (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:49.188Z)
OS version: Darwin x64 20.6.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 3, 4
Memory (System) 64.00GB (2.29GB free)
Process Argv --crash-reporter-id 024bf4e4-11bc-4008-aa5e-c3d69ed66fab
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonvspyt551cf:30345471
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30451275
dsvsc009:30452663
pythonvsnew555:30457759
vscscmwlcmc:30438804
pynewfile477cf:30450039

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 22, 2022
@MatrixManAtYrService MatrixManAtYrService changed the title Linting over and over even with no changes Linting over and over, and electron process at 100% CPU, even without making changes Mar 22, 2022
@karthiknadig
Copy link
Member

It seems to be using alpha version of python (3.10.0a6), does it occur with stable versions as well?

@MatrixManAtYrService
Copy link
Author

Oh good catch, I had forgotten about that. I've recreated the venv, it now says:

venv ❯ python -c "import sys;print(sys.version)"
3.10.2 (main, Mar 23 2022, 09:51:47) [Clang 12.0.5 (clang-1205.0.22.9)]

If the problem doesn't come up in the next few days I think we can say that that was to blame. I'll report back when I know.

@MatrixManAtYrService
Copy link
Author

MatrixManAtYrService commented Mar 23, 2022

Well that was quick. It came back right away. I try different python versions in this venv, see if I can find a pattern.

I think github is optimizing out most of the action here, but the problems counter is quickly counting up from 0 and back.
2022-03-22 15 30 48

@karthiknadig karthiknadig self-assigned this Mar 23, 2022
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug area-linting info-needed Issue requires more information from poster triage and removed triage-needed Needs assignment to the proper sub-team labels Mar 23, 2022
@karthiknadig
Copy link
Member

@MatrixManAtYrService Can you look at the problems window and see if the problem is reported via flake8 or pylance?

@MatrixManAtYrService
Copy link
Author

MatrixManAtYrService commented Mar 24, 2022

It looks like its flake8. I took a screenshot:

Screen Shot 2022-03-23 at 11 11 28 PM

I was hoping to just lint my code, but it looks like it's going on quite a spree. I don't really need to lint these files, as I'm not editing them:

  • ~/.pyenv/versions/3.10.2/lib/python3.10/encodings/idna.py
  • ~/.vscode/extensions/ms-python.vscode-pylance-2022.3.2/dis/typeshed-fallback/stdlib/urllib/request.pyi

I have a git repo rooted in my home directory (with a very aggressive .gitignore, I use it to sync files between machines). Maybe something is looking for the "repo root" and instead of stopping at the project folder it's going all the way up to my home directory? That would explain why it's got a too-wide scope.

I'll rename ~/.git -> ~/git.bak and we'll see if it goes away.

@MatrixManAtYrService
Copy link
Author

Update: even after removing the enclosing git repo, it still occasionally gets stuck in a loop where it lints more than just my code over and over.
2022-03-25 13 48 23

@MatrixManAtYrService MatrixManAtYrService changed the title Linting over and over, and electron process at 100% CPU, even without making changes Linting more than just my code in an infinite loop Mar 25, 2022
@karthiknadig
Copy link
Member

@MatrixManAtYrService Can you try this prototype extension to see if this helps with your issue? PyCQA/flake8#1467 (comment)

That is a new direction we are beginning to take with linting. We recently published pre-release version of that extension for pylint. That extension run the linter as a server and works with it over Language Server Protocol. IT should behave better in scenarios like this.

@MatrixManAtYrService
Copy link
Author

Ok. Based on the settings description when I installed the extension, I also made these changes to my settings:

  // "python.linting.flake8Enabled": true,
  // "python.linting.flake8Args": [
  //   "--max-line-length=120",
  //   "--ignore=E402,E302,E305,E266,W503,E127,E241,E128,E201,E203,E202,F811,E501"
  // ],
  // "python.linting.flake8Path": "/usr/local/bin/flake8",
  "python.flake8Args": [
    "--max-line-length=120",
    "--ignore=E402,E302,E305,E266,W503,E127,E241,E128,E201,E203,E202,F811,E501"
  ],
  "python.flake8Path": [
    "/usr/local/bin/flake8"
  ],

It appears to be working, but I can't be sure that anything meaningful has changed without giving it some time. I'll use it for a while and report back. Thank you for your help.

@MatrixManAtYrService
Copy link
Author

It happened to me again while using the recommended extension 😦

@karthiknadig
Copy link
Member

@MatrixManAtYrService Can you copy the Output from Output> Flake8?

@MatrixManAtYrService
Copy link
Author

At this moment it shows:

Linter Name: Flake8
Linter Module: flake8
file:///Users/matt/src/qa-outer-dags/plugins/models.py :

file:///Users/matt/src/qa-outer-dags/plugins/batch_runner.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/dags/cases/operator_expansion.py :

file:///Users/matt/src/qa-outer-dags/plugins/assertions.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/tasks.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/batch_runner.py :

file:///Users/matt/src/qa-outer-dags/plugins/assertions.py :

file:///Users/matt/src/qa-outer-dags/plugins/tasks.py :

file:///Users/matt/src/qa-outer-dags/plugins/models.py :
'48,5,E,E303:too many blank lines (2)'
'49,5,E,E301:expected 1 blank line, found 0'
'293,25,E,E225:missing whitespace around operator'
'294,9,E,E999:SyntaxError: positional argument follows keyword argument'

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/tesults_summary.py :

file:///Users/matt/src/qa-outer-dags/plugins/tasks.py :

file:///Users/matt/src/qa-outer-dags/plugins/models.py :
'48,5,E,E303:too many blank lines (2)'
'49,5,E,E301:expected 1 blank line, found 0'
'293,25,E,E225:missing whitespace around operator'
'294,9,E,E999:SyntaxError: positional argument follows keyword argument'

file:///Users/matt/src/qa-outer-dags/plugins/models.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/batch_runner.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/tasks.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/airflow/airflow/models/taskinstance.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/src/qa-outer-dags/plugins/tasks.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

file:///Users/matt/.pyenv/versions/3.10.2/lib/python3.10/test/__init__.py :

It's not doing the annoying thing right now though. I'll try to catch it next time it does the thing too.

@karthiknadig
Copy link
Member

@MatrixManAtYrService Would it be possible for you to share the list of extensions you have installed? you can find them under ~/.vscode/extensions. Just do a ls in that directory and share the result.

@MatrixManAtYrService
Copy link
Author

Sure:

❯ ls ~/.vscode/extensions
eamodio.gitlens-12.0.5                              ms-vscode-remote.remote-containers-0.231.2
genuitecllc.codetogether-2022.1.3                   ms-vscode-remote.remote-containers-0.231.3
genuitecllc.codetogether-2022.1.4                   ms-vscode-remote.remote-ssh-0.76.1
kanadig.python-flake8-0.0.1                         ms-vscode-remote.remote-ssh-0.78.0
ms-azuretools.vscode-docker-1.21.0                  ms-vscode-remote.remote-ssh-edit-0.78.0
ms-python.python-2022.4.0                           ms-vscode-remote.remote-ssh-edit-0.80.0
ms-python.vscode-pylance-2022.3.4                   ms-vscode-remote.remote-wsl-0.64.2
ms-toolsai.jupyter-2022.2.1030672458                ms-vscode-remote.remote-wsl-0.66.0
ms-toolsai.jupyter-2022.3.1000901801                ms-vscode-remote.vscode-remote-extensionpack-0.21.0
ms-toolsai.jupyter-keymap-1.0.0                     ms-vscode.js-debug-companion-1.0.17
ms-toolsai.jupyter-renderers-1.0.6                  redhat.vscode-yaml-1.6.0
ms-vscode-remote.remote-containers-0.231.1          stuart.unique-window-colors-1.0.51

@karthiknadig
Copy link
Member

@MatrixManAtYrService So, something is triggering the python3.10/test/__init__.py to open. The flake8 extension handles onOpen, onSave, and onClose, events on files. Those are the only supported handlers, so something is opening and closing this file rapidly in the editor. Not sure why that is occurring.

Also, it looks like you might have stale copies of several extension. Would it be possible for you to delete the stale ones and reload VS Code?

@MatrixManAtYrService
Copy link
Author

I assume that "stale" here means the ones with the older version numbers. I've deleted them, so here's the slightly smaller list:

❯ ls ~/.vscode/extensions
eamodio.gitlens-12.0.5                              ms-vscode-remote.remote-containers-0.231.3
genuitecllc.codetogether-2022.1.4                   ms-vscode-remote.remote-ssh-0.78.0
kanadig.python-flake8-0.0.1                         ms-vscode-remote.remote-ssh-edit-0.80.0
ms-azuretools.vscode-docker-1.21.0                  ms-vscode-remote.remote-wsl-0.64.2
ms-python.python-2022.4.0                           ms-vscode-remote.vscode-remote-extensionpack-0.21.0
ms-python.vscode-pylance-2022.3.4                   ms-vscode.js-debug-companion-1.0.17
ms-toolsai.jupyter-2022.3.1000901801                redhat.vscode-yaml-1.6.0
ms-toolsai.jupyter-keymap-1.0.0                     stuart.unique-window-colors-1.0.51
ms-toolsai.jupyter-renderers-1.0.6

I'll leave that output window open while I code and see if I notice any correlation between my activities and those open events. Thanks for your help with this.

@MatrixManAtYrService
Copy link
Author

MatrixManAtYrService commented Apr 8, 2022

I haven't had the stuck-in-loop thing happen since I deleted the stale plugins, and for the most part my flake8 output looks normal. Every now and then, though, I do get one of these in it:

file:///Users/matt/.vscode/extensions/ms-python.vscode-pylance-2022.4.0/dist/typeshed-fallback/stdlib/builtins.pyi :
'81,5,E,E704:multiple statements on one line (def)'

Even though I haven't opened that file

@brettcannon brettcannon removed the info-needed Issue requires more information from poster label Apr 28, 2022
@karthiknadig karthiknadig added triage-needed Needs assignment to the proper sub-team and removed triage labels May 4, 2022
@karthiknadig
Copy link
Member

@MatrixManAtYrService If you run into this issue again, i recommend disabling linting on the python extension and try the flake8 extension (currently in pre-release): https://marketplace.visualstudio.com/items?itemName=ms-python.flake8

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants