Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff server does not support E30* errors? #10814

Closed
a1401358759 opened this issue Apr 7, 2024 · 11 comments
Closed

ruff server does not support E30* errors? #10814

a1401358759 opened this issue Apr 7, 2024 · 11 comments
Labels
server Related to the LSP server

Comments

@a1401358759
Copy link

ruff version: 0.3.5
lsp ocnfig:

return {
  filetypes = { "python" },
  single_file_support = true,
  cmd = { "ruff", "server", "--preview", "--config", "~/.config/nvim/pyproject.toml" },
  settings = {
    args = options.ruff_args,
  },
}

pyproject.tmol

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = ["E402","E501","N802","N803","N806","N801","N813","N815","N816","RUF001","RUF002","RUF003","RUF012","ARG001"]
extend-select = ["E", "N", "W", "ARG", "RUF"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

but i did not get any errors
image

@charliermarsh
Copy link
Member

Can you try adding preview = true to your pyproject.toml, under [tool.ruff]?

@charliermarsh charliermarsh added the server Related to the LSP server label Apr 7, 2024
@a1401358759
Copy link
Author

a1401358759 commented Apr 8, 2024

@charliermarsh

[tool.ruff]
preview = true
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 120
indent-width = 4

It's still not working.Did I make a mistake?

@MichaReiser
Copy link
Member

@a1401358759 did you keep your existing lint configuration?

[tool.ruff]
preview = true
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 120
indent-width = 4

[tool.ruff.lint]

# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = ["E402","E501","N802","N803","N806","N801","N813","N815","N816","RUF001","RUF002","RUF003","RUF012","ARG001"]
extend-select = ["E", "N", "W", "ARG", "RUF"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

@a1401358759
Copy link
Author

a1401358759 commented Apr 8, 2024

@MichaReiser this is my whole config

[tool.ruff]
preview = true
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 120
indent-width = 4

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = ["E402","E501","N802","N803","N806","N801","N813","N815","N816","RUF001","RUF002","RUF003","RUF012","ARG001"]
extend-select = ["E", "N", "W", "ARG", "RUF"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

@MichaReiser
Copy link
Member

MichaReiser commented Apr 8, 2024

Hm okay. This works for me but I use the old LSP (and vscode).

Can you try removing the

settings = {
    args = options.ruff_args,
  },

because the new server doesn't yet support options (but I'm just guessing at this point).

@snowsignal do you have an idea what's going on here?

@a1401358759
Copy link
Author

@MichaReiser I try removing the

settings = {
    args = options.ruff_args,
  },

but it's still not working,ruff-lsp works good for me.

@dhruvmanila
Copy link
Member

Hey @a1401358759, I don't think the new server supporst configuring Ruff via the global --config flag or a local configuration file.

@snowsignal Correct me if I'm wrong here.

@snowsignal
Copy link
Member

@a1401358759 Right now the new server has a few limitations, especially around configuration. At the moment, we don't support configuring the server with the --config flag, nor do we support the args field in settings (like @dhruvmanila and @MichaReiser mentioned). Alternative configuration is something we're actively working on, but at the moment the configuration just defaults to any pyproject.toml / ruff.toml files at the root of your workspace or in parent folders.

Thank you for opening this issue - I'll follow up once we have a setting like this available.

@a1401358759
Copy link
Author

@snowsignal Okay, thank you very much for your answer.

@snowsignal snowsignal added this to the Ruff Server: Beta milestone Apr 10, 2024
@snowsignal
Copy link
Member

snowsignal commented May 3, 2024

@a1401358759 Once #11140 lands in the next release, you should be able to specify a custom configuration file!

Here's what your LSP config could look like:

return {
  filetypes = { "python" },
  single_file_support = true,
  cmd = { "ruff", "server", "--preview", },
  settings = {
    configuration = "~/.config/nvim/pyproject.toml"
  },
}

The configuration setting is what you should use to specify the configuration file.

Let me know if you run into any more issues!

@a1401358759
Copy link
Author

my lsp config

return {
  filetypes = { "python" },
  single_file_support = true,
  cmd = { "ruff", "server", "--preview" },
  settings = {
    configuration = "~/.config/nvim/pyproject.toml",
  },
}

my pyprohect.toml

[tool.ruff]
preview = true
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 120
indent-width = 4

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = ["E402","E501","N802","N803","N806","N801","N813","N815","N816","RUF001","RUF002","RUF003","RUF012","ARG001"]
extend-select = ["E", "N", "W", "ARG", "RUF"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

but ruff server still doesn't check E30* errors

image

Is there still a problem with my configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server
Projects
None yet
Development

No branches or pull requests

5 participants