ruff claims to be able to replace isort
Is it true?
Anyone want to give this a go?
Files to modify would be:
https://github.com/pandas-dev/pandas/blob/c73736cead833ae265d99c467978708dcc0ae5d7/.pre-commit-config.yaml#L94-L97
https://github.com/pandas-dev/pandas/blob/c73736cead833ae265d99c467978708dcc0ae5d7/pyproject.toml#L187-L255
isort works on cython files, so we should check that ruff actually does those too
Comment From: Batalex
Ruff does not yet support all isort's options. The best I could do with the latest version (0.238.0) is the following minimal config:
[tool.ruff]
...
select = [
...
"I"
]
[tool.ruff.isort]
combine-as-imports = true
force-sort-within-sections = true
which reports almost 650 violations in pandas
directory
ruff --select I pandas --statistics
648 I001 Import block is un-sorted or un-formatted
I might have missed something, but I could not get a better result.
Moreover, upgrading ruff to get the force-sort-within-section
option which is absent in 0.215.0 adds a ton of new violations.
ruff pandas --statistics
1 F821 Undefined name `MaskedUInt8Engine`
1663 PLR2004 Magic value used in comparison, consider replacing 4 with a constant variable
655 PLR0913 Too many arguments to function call (8/5)
648 I001 Import block is un-sorted or un-formatted
Oh, and ruff works on .py and .pyi files, but not on .pyx files.
Comment From: MarcoGorelli
thanks @Batalex for investigating, much appreciated! ok let's close for now then