koxudaxi / ruff-pycharm-plugin

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

Use a relative path for ruff executable in the configuration file #343

Open clement-escolano opened 7 months ago

clement-escolano commented 7 months ago

Is your feature request related to a problem? Please describe. In the project I am currently working on, we all use PyCharm and share some of the IDE configurations (stored in the .idea folder). We would like to share the configuration of the Ruff plugin but this is not possible currently as not all developers installed Python in the same way and the path of ruff executable is not the same for everyone and this path is written in the ruff.xml configuration file.

Describe the solution you'd like A way to share the ruff.xml file with people that don't have the same path to ruff. Some ideas (I don't know if there are feasible):

Describe alternatives you've considered Not having the path in the file works (the plugin auto-detects it probably) but from time to time (mostly when opening the Ruff plugin in the settings modal), the ruff.xml file is modified to add the path which makes it cumbersome to the other people.

Additional context None

koxudaxi commented 6 months ago

@clement-escolano I'm sorry for my late reply. Thank you for your creating the issue. OK, I will check your suggestion to see whether I can implement it.

KotlinIsland commented 5 months ago

This is a very important issue that needs addressing. I am willing to implement a fix. Could you point me in the right direction?

koxudaxi commented 5 months ago

@KotlinIsland I'm sorry. I haven't looked into it yet, I will investigate this weekend.

KotlinIsland commented 5 months ago

@koxudaxi This field isn't editable (#379), Can we just not save it to the XML file?

koxudaxi commented 5 months ago

@KotlinIsland detectRuffExecutable writes the python path in the xml file by using RuffConfigService. I can see the path in the xml. https://github.com/koxudaxi/ruff-pycharm-plugin/blob/d5fc96f277f20780d7ac2546d899b16d6150b4d8/src/com/koxudaxi/ruff/Ruff.kt#L129

https://github.com/koxudaxi/ruff-pycharm-plugin/blob/d5fc96f277f20780d7ac2546d899b16d6150b4d8/src/com/koxudaxi/ruff/RuffConfigService.kt#L11

image

image

KotlinIsland commented 5 months ago

I would recommend against using $PROJECT_DIR$ and instead use $PyInterpreterDirectory$, it would be highly unlikely that a project would include an exe for ruff outside the venv, and some venvs are not within the project dir (poetry)