nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Formatting with the ruff linter (should not be confused with their formatter) is broken

Mishosan opened this issue · comments

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Issues

  • I have checked existing issues and there are no issues with the same problem.

Neovim Version

0.9.4

Dev Version?

  • I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.

Operating System

Pop!_OS

Minimal Config

local present, null_ls = pcall(require, "null-ls")

if not present then
  return
end

local b = null_ls.builtins

local sources = {
  -- Python
  b.diagnostics.ruff,
  b.formatting.ruff,
  b.formatting.ruff_format,
  b.diagnostics.mypy,
}

null_ls.setup {
  debug = true,
  sources = sources,
}

Steps to Reproduce

I am using the NvChad preconfig and the minimal config is among my custom configs, and I have the latest version of ruff and the latest version of none-ls installed.

Reproducibility Check

  • I confirm that my minimal config is based on the minimal_init.lua template and that my issue is reproducible by running nvim --clean -u minimal_init.lua and following the steps above.

Expected Behavior

File before:

from functools import partial
from time import monotonic
from enum import Enum, auto
from uuid import UUID
import sys, os, re

def main() -> None:
    pass

if __name__ == "__main__":
    main()

What it should look like after:

import re
import sys
from enum import Enum, auto
from functools import partial
from time import monotonic
from typing import Any
from uuid import UUID


def main() -> None:
    pass

if __name__ == "__main__":
    main()

Actual Behavior

This is what actually happens:

sorting_stuff_2.py:1:20: F401 `typing.Any` imported but unused
sorting_stuff_2.py:2:23: F401 `functools.partial` imported but unused
sorting_stuff_2.py:3:18: F401 `time.monotonic` imported but unused
sorting_stuff_2.py:4:18: F401 `enum.Enum` imported but unused
sorting_stuff_2.py:4:24: F401 `enum.auto` imported but unused
sorting_stuff_2.py:5:18: F401 `uuid.UUID` imported but unused
sorting_stuff_2.py:6:1: E401 Multiple imports on one line
sorting_stuff_2.py:6:8: F401 `sys` imported but unused
sorting_stuff_2.py:6:13: F401 `os` imported but unused
sorting_stuff_2.py:6:17: F401 `re` imported but unused
Found 11 errors.
[*] 1 fixable with the `--fix` option.

Debug Log

The null-ls.log file is 6003 lines long, so I think I'll skip pasting it here.

Help

Yes

Implementation Help

Reverting ALL of the changes made by this pull request should solve this issue. Also, see this issue.

Requirements

  • I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.

This commit fixed it, so it's not an issue anymore.