astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
33.1k stars 1.11k forks source link

ruff freezes when running with --stdin-filename #14530

Closed Guust-Franssens closed 3 days ago

Guust-Franssens commented 3 days ago
$ ruff check --stdin-filename src/__init__.py  --verbose --isolated
[2024-11-22][14:49:35][ruff::resolve][DEBUG] Isolated mode, not reading any pyproject.toml

however running it without specifying --stdin-filename works without any problem

$ ruff check src/__init__.py --verbose --isolated
[2024-11-22][14:51:18][ruff::resolve][DEBUG] Isolated mode, not reading any pyproject.toml
[2024-11-22][14:51:18][ruff::commands::check][DEBUG] Identified files to lint in: 3.3689ms
[2024-11-22][14:51:18][ruff::diagnostics][DEBUG] Checking: C:\Users\gfranssens\vscode-projects\belgian-journal\src\__init__.py
[2024-11-22][14:51:18][ruff::commands::check][DEBUG] Checked 1 files in: 12.029ms
All checks passed!

I have tried running on many versions however all with same problem (minor version 0.5, 0.6, 0.7). I was currently using the latest version.

$ ruff version
ruff 0.8.0 (a90e404c3 2024-11-22)

the reason that this is a problem is because the VSCode extension runs in the background with --stdin-filename thus no corrections are done on save.

I believe the problem is related to something on my machine, however I cannot figure out what is the problem... Hopefully someone knows a fix...

MichaReiser commented 3 days ago

Ruff expects that you pass a file via stdin when you specify --stdin-filename like this:

ruff check --stdin-filename test.py < ../test/c.py
Guust-Franssens commented 3 days ago

@MichaReiser thanks already, make sense....

when I check the VSCode output for the ruff extension I see the following; afterwhich it freezes. I assume I should be this instead on the vscode-ruff extension?

2024-11-22 15:51:16.631 [info] Using environment executable: C:\Users\gfranssens\.local\bin\ruff.EXE
2024-11-22 15:51:16.632 [info] Found ruff 0.8.0 at C:\Users\gfranssens\.local\bin\ruff.EXE
2024-11-22 15:51:16.632 [info] Running Ruff with: C:\Users\gfranssens\.local\bin\ruff.EXE ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', 'c:\\Users\\gfranssens\\vscode-projects\\belgian-journal\\src\\spiders\\legal_entities.py']
MichaReiser commented 3 days ago

Can you explain with what you mean by freeze? I don't think ruff prints any other messages after Running Ruff with. Do you see violations in your editor? Does the output get updated when you change and save a file?

Guust-Franssens commented 3 days ago

My VSCode settings for Ruff were improplerly configured....