Open koxudaxi opened 1 year ago
Hi @koxudaxi ,
could you please try with my exact same ruff config in pyproject.toml?
[tool.ruff]
line-length = 120
target-version = "py37"
select = ["A", "B", "C4", "D", "E", "EXE", "F", "FBT", "G", "I", "ICN", "ISC", "N", "PIE", "PL", "Q003", "PT", "Q", "RSE", "RUF", "S", "SIM", "T10", "T20", "TID", "UP", "W", "YTT"]
ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D106","D107", "G003", "G004", "PLR0913", "PLR2004", "S113", "SIM108"]
format = "grouped"
[tool.ruff.pydocstyle]
convention = "google"
[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.ruff.flake8-quotes]
inline-quotes = "double"
docstring-quotes = "double"
multiline-quotes = "double"
Apart from the ignored files section I've copied the complete ruff config from one of the projects affected by this.
Just added an error in the code and noticed that the ruff plugin is working on this project now. I'll post again if I notice anything.
@xyxz-web Thank you for sharing the example. I have tried the config. But, It works fine in my local.
Could you please share the plugin version, ruff version, and ruff config?
my environment are IDE: PyCharm 2023.2.1 (Professional Edition) OS: macOS 14 Ruff Version 0.1.1 Plugin version 0.0.24
Hi @koxudaxi ,
as mentioned in my second comment it is actually working now. The only change between when it did not work was that I did upgrade several dependencies and restart PyCharm after activating the ruff-lsp option.
Best regards
I did upgrade several dependencies
After the dependencies are installed, and PyCharm has re-detected the package, the plugin will re-set the path to the ruff.
restart PyCharm after activating the ruff-lsp option.
ruff-lsp is not enabled before restarting PyCharm. Should we show a popup dialog to restart? :thinking:
Yes I think it might be a good Idea to show a popup that a restart is needed.
I think the pyproject.toml
discovery differs between the plugin and running ruff
via command-line.
https://docs.astral.sh/ruff/configuration/#config-file-discovery (permalink)
(Note that passing the configuration file explicitly via --config
disables the intelligent auto-discovery of the closest configuration file to the subject python file)
I observed the subject issue within a Pycharm project where the content root doesn't contain the .idea directory. Something like this:
~/PycharmProjects/foo-project/.idea/
~/dev/foo/ # this is the content root
~/dev/foo/.venv/ # virtual environment with ruff binary used by the Ruff plugin
"Ruff config file" was left empty in the plugin configuration.
I placed ruff.toml
both in ~/PycharmProjects/foo-project/
and in ~/dev/foo/
, and tried to format some python files in ~/dev/foo/
:
~/PycharmProjects/foo-project/ruff.toml
ruff
binary from command-line used ~/dev/foo/ruff.toml
, regardless of current working directory~/PycharmProjects/foo-project/ruff.toml
, the plugin used default ruff settings.Note that there may be many content roots in a PyCharm project.
I have the same issue. In the pyproject.toml
file in the section tool.ruff.lint.per-file-ignores
I have an entry "__init__.py" = ["PLC0414"]
, which in the Pycharm show me an error PLC0414
. But when I run ruff with CLI everything is ok. Is it any update to this issue? I'm running on the WSL2 env. Feel free to ask me about project information, I would like to help to trace this error.
I am also having the same issue as above i.e. [tool.ruff.lint.per-file-ignores]
rules are being ignored from pyproject.toml
when using the PyCharm plugin, where other settings are working correctly e.g. [tool.ruff.lint]
.
Running ruff
via the command-line detects the [tool.ruff.lint.per-file-ignores]
settings and hence the issue appears isolated to (1) the ruff-plugin and (2) per-file-ignores
settings specifically.
Environment: OS: RHEL9 PyCharm: 2024.2.3 (Community Edition) ruff version: ruff 0.6.9 ruff-plugin: 0.0.41
Describe the bug Several users have pointed out a problem with config information in
pyproject.toml
andruff.toml
not being read. However, the config information is applied when theruff
command is invoked directly from the terminal.I could not reproduce the problem in my environment, so I have created this issue to sort out and resolve the issue.
To Reproduce Steps to reproduce the behavior:
pyproject.toml
orruff.toml
in a project.Expected behavior The plugin doesn't show wrong waring (respect configs)
Screenshots I can't reproduce the problem
Environments (please complete the following information):
Related Issues https://github.com/koxudaxi/ruff-pycharm-plugin/issues/277 https://plugins.jetbrains.com/plugin/20574-ruff/reviews#review=91176-91183 https://plugins.jetbrains.com/plugin/20574-ruff/reviews#review=90927-91184