ruff/isort: rule mismatch for natural ordering in cki-tools/tests/test_amqp_bridge.py
isort produces (10 < 91):
from cki_tools import amqp_bridge
from cki_tools.amqp_bridge import amqp10
from cki_tools.amqp_bridge import amqp091
from cki_tools.amqp_bridge import sqs
from cki_tools.amqp_bridge import utils
and ruff check
, with I001
enabled, produces ('0' < '1'):
from cki_tools import amqp_bridge
-from cki_tools.amqp_bridge import amqp10
from cki_tools.amqp_bridge import amqp091
+from cki_tools.amqp_bridge import amqp10
from cki_tools.amqp_bridge import sqs
from cki_tools.amqp_bridge import utils
Digging a bit, it looks like ruff should be able to use natural ordering1, which is default in isort 2. I couldn't find if there's a way to toggle natural sorting with ruff, but it doesn't seem like an expected divergence 3. Might be a regression, but we'd need to open an issue upstream with a minimal example.
ruff uses natord
which treats numbers with leading zero as strings, i.e. they are sorted like you would sort decimals, e.g. "0.003, 0.02, 0.1", while isort just cast the numbers to integers, so that the last example would become "3, 2, 1".
AC:
-
Add this divergence to ruff docs upstream -
toggle isort's --sort-order=native
to match ruff on our cases cki-lib!878 (merged) -
disable isort altogether and rely on ruff to check import ordering
Edited by Tales da Aparecida