koxudaxi / ruff-pycharm-plugin

PyCharm plugin for ruff. This plugin provides reformat code using ruff.
MIT License
196 stars 9 forks source link

error: unexpected argument '--format' found #295

Closed grundew closed 9 months ago

grundew commented 10 months ago

I get the following error when ruff is triggered with save file

caused by: The following command was executed:

C:\Users\gw\venv311\Scripts\ruff.exe --exit-zero --no-cache --force-exclude --no-fix --format json --stdin-filename sb_mictest/test_hw/mic_test/test_mic_membrane_disable.py -

The exit code: 2 The error output of the command:

error: unexpected argument '--format' found

tip: to pass '--format' as a value, use '-- --format'

Usage: ruff.exe check <FILES|--fix|--no-fix|--unsafe-fixes|--no-unsafe-fixes|--show-source|--no-show-source|--show-fixes|--no-show-fixes|--diff|--watch|--fix-only|--no-fix-only|--ignore-noqa|--output-format |--output-file |--target-version |--preview|--no-preview|--config |--select |--ignore |--extend-select |--extend-ignore |--per-file-ignores |--extend-per-file-ignores |--exclude |--extend-exclude |--fixable |--unfixable |--extend-fixable |--extend-unfixable |--respect-gitignore|--no-respect-gitignore|--force-exclude|--no-force-exclude|--line-length |--dummy-variable-rgx |--no-cache|--isolated|--cache-dir |--stdin-filename |--exit-zero|--exit-non-zero-on-fix|--statistics|--add-noqa|--show-files|--show-settings|--ecosystem-ci>

For more information, try '--help'.

Error Running Ruff at com.koxudaxi.ruff.RuffKt.runCommand(Ruff.kt:241) at com.koxudaxi.ruff.RuffKt.runCommand(Ruff.kt:180) at com.koxudaxi.ruff.RuffKt.runRuff(Ruff.kt:319) at com.koxudaxi.ruff.RuffExternalAnnotator.doAnnotate(RuffExternalAnnotator.kt:57) at com.koxudaxi.ruff.RuffExternalAnnotator.doAnnotate(RuffExternalAnnotator.kt:22) at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:207) ... 37 more

python 3.11 ruff 0.1.2

koxudaxi commented 10 months ago

Thank you for creating the issue. I will check it tonight.

owendaw commented 10 months ago

it looks like --format has been replaced with --output-format in ruff 0.1.0 @koxudaxi

See Breaking Changes: https://github.com/astral-sh/ruff/blob/fe9727ac38db6d3b8ab3efcbf4e1766eb2ec9736/BREAKING_CHANGES.md

For now you can downgrade your version of ruff. Version prior to format change is 0.0.292 @grundew

koxudaxi commented 10 months ago

@owendaw I had applied the changes. https://github.com/koxudaxi/ruff-pycharm-plugin/pull/268 It works in my environment.

Could you please show us your environment? I tried to test in Windows too. I couldn't reproduce the error.

The plugin changes the execution argument by ruff version. https://github.com/koxudaxi/ruff-pycharm-plugin/blob/aa7f1cd68863b1eb44e4ed38916fc7a57bc5a538/src/com/koxudaxi/ruff/RuffVersion.kt#L14-L18 I guess the plugin can't detect the ruff version sometimes.

owendaw commented 10 months ago

@koxudaxi I took a look through the repo and see what you're saying

I am on MacOS Sonoma 14.1 - Apple Silicon Python 3.12 via pyenv - have seen the same result trying python 3.9 as well I have tried this with ruff 0.1.5 and 0.1.2

I have tried to debug a little using different approaches - looking at file permissions, using virtual environments vs system interpreters. These have not been successful

Weirdly enough the only time I am able to open Pycharm and not get this error with a version of ruff >= 0.1.0 is when first clearing the cache and restarting. Every time after the issue arises.

My though is that the error could be a result of the asynchronous version setting via setVersionFromCommand. Perhaps NO_FIX_ARGS is being set prior to the async completion

https://github.com/koxudaxi/ruff-pycharm-plugin/blob/aa7f1cd68863b1eb44e4ed38916fc7a57bc5a538/src/com/koxudaxi/ruff/Ruff.kt#L84C1-L84C126

I know JetBrains has a separate installer for Apple Silicon, have you tried to recreate that env?

koxudaxi commented 10 months ago

@owendaw Thank you for investigating the issue. I have created the PR. I will test the new version before releasing it!!