koxudaxi / ruff-pycharm-plugin

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

PyCharm Reformat Code feature not working #406

Closed seandearnaley closed 3 months ago

seandearnaley commented 3 months ago

I recently installed ruff at our company, several users have reported that pycharm reformat does not use ruff, we're using ruff 0.3.2, extension version 0.0.31, pycharm 2023.3.5, mac m1 sonoma 14.4.1. same settings as user but tried all of them and it does not work, just uses the pycharm formatter. tried local and remote interpreters, doesn't seem to work at all. I wonder if you've had a regression somewhere? works in vs code, format command line fine.

these are my settings but I've tried checking off lsp, checking off format, it's confusing that it has 2 options for formatting, but it doesn't work either way.

Screenshot 2024-03-29 at 9 59 02 AM

I see this error in the stacktrace but it's odd because I had checked off ruff-lsp:

ExternalToolPass: 

com.intellij.diagnostic.PluginException: annotator: com.koxudaxi.ruff.RuffExternalAnnotator@3f03077b (class com.koxudaxi.ruff.RuffExternalAnnotator) [Plugin: com.koxudaxi.ruff]
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:89)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.processError(ExternalToolPass.java:253)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:212)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:203)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$0(ExternalToolPass.java:164)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.runChangeAware(ExternalToolPass.java:268)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$2(ExternalToolPass.java:164)
    at com.intellij.openapi.progress.util.BackgroundTaskUtil.lambda$runUnderDisposeAwareIndicator$15(BackgroundTaskUtil.java:371)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:192)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:610)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:685)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:641)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:609)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:78)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:179)
    at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:366)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.run(ExternalToolPass.java:162)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:81)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:81)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:86)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:81)
    at com.intellij.util.ui.update.Update.runUpdate(Update.java:113)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:348)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:338)
    at com.intellij.util.ui.update.MergingUpdateQueue.doFlush(MergingUpdateQueue.java:295)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:277)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:246)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:81)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:81)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:86)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:81)
    at com.intellij.util.Alarm$Request.lambda$runSafely$0(Alarm.java:369)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:253)
    at com.intellij.util.Alarm$Request.runSafely(Alarm.java:369)
    at com.intellij.util.Alarm$Request.run(Alarm.java:356)
    at com.intellij.util.concurrency.Propagation.contextAwareCallable$lambda$2(propagation.kt:357)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:272)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:244)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:30)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:222)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: The following command was executed:

/opt/homebrew/bin/ruff-lsp --exit-zero --no-cache --force-exclude --no-fix --output-format json --stdin-filename organizations/lib/digest_email/digest_email.py --config /Users/seandearnaley/Documents/GitHub/claritytuition-backend/pyproject.toml -

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

usage: ruff-lsp [-h] [--version]
ruff-lsp: error: unrecognized arguments: --exit-zero --no-cache --force-exclude --no-fix --output-format json --stdin-filename organizations/lib/digest_email/digest_email.py --config /Users/seandearnaley/Documents/GitHub/claritytuition-backend/pyproject.toml -

Error Running Ruff
    at com.koxudaxi.ruff.RuffKt.runCommand(Ruff.kt:258)
    at com.koxudaxi.ruff.RuffKt.runCommand(Ruff.kt:197)
    at com.koxudaxi.ruff.RuffKt.runRuff(Ruff.kt:347)
    at com.koxudaxi.ruff.RuffExternalAnnotator.doAnnotate(RuffExternalAnnotator.kt:59)
    at com.koxudaxi.ruff.RuffExternalAnnotator.doAnnotate(RuffExternalAnnotator.kt:23)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:209)
    ... 47 more
seandearnaley commented 3 months ago

thank you @koxudaxi !, will test this afternoon