nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.43k stars 72 forks source link

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

Closed Mishosan closed 9 months ago

Mishosan commented 9 months ago

FAQ

Issues

Neovim Version

0.9.4

Dev 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

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

Mishosan commented 9 months ago

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