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
Remove isort, enable ruff's isort rules and apply them #5055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In YOLOs we trust. The dependency changes look good, but I only looked through a quarter of the change incurred due to the applications of isort rules.
ignore = [ | ||
"E501", # pycodestyle: line-too-long | ||
"PIE808", # unnecessary-range-start | ||
"RUF012", # mutable-class-default - see https://github.com/astral-sh/ruff/issues/5243 | ||
] | ||
|
||
[tool.ruff.lint.isort] | ||
combine-as-imports = true | ||
force-sort-within-sections = true | ||
order-by-type = false | ||
section-order = ["future", "standard-library", "third-party", "nautobot", "first-party", "local-folder"] | ||
|
||
[tool.ruff.lint.isort.sections] | ||
"nautobot" = ["nautobot"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why GitHub is considering this invalid - as far as I can tell it's correct TOML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened github support ticket 2514042 on it
Can you update |
Oof, I'd forgotten that we had such detailed prescriptivism in the docs that isn't currently enforced by any tooling. At a quick glance, I don't see exactly what needs to be updated for this PR though - any specific pointers? |
I was thinking just an annotation on how to use ruff to format your imports somewhere near the top. |
Added a note to the docs and improved the |
Closes: #n/a
What's Changed
isort
dev dependency (was never automatically used or enforced) - note that it actually stays in poetry.lock because it's a transitive dependency ofpylint
, but we can't do anything about that for now...I
rule set and configure it inpyproject.toml
to most closely approximate our current conventions (I'm absolutely open to suggested changes here, see https://docs.astral.sh/ruff/settings/#isort for options)nautobot
as its own group of imports to get placed before imports from within the example plugin, as this seems to match our current convention most closely.invoke ruff --fix
and let it rearrange imports to its heart's content.nautobot.core.models
andnautobot.extras.models
, I had to add# isort:skip
to prevent a very small number of changes innautobot.circuits.models
andnautobot.dcim.models.cables
that would have triggered circular import errors if moved.TODO