Introduce sort-all Hook for pre-commit#4052
Conversation
|
It's not a lot of code maybe it makes sense to build smth for us with slots and all? |
|
@Poolitzer that's what I was thinking as well, maybe open an issue in Ruff, cause it will get implemented pretty quickly if accepted |
Have already forked :D https://github.com/Bibo-Joshi/sort-all
also a nice idea! would you mind doing that? Things to mention IMO are
If you like the idea in general, I'd like to go ahead with the package that we have so far :) |
|
@Bibo-Joshi @clot27 points to astral-sh/ruff#1198 in which it's mentioned that isort can do this already. I'll have to check |
|
|
|
PyCQA/isort#2193 also mentions https://pypi.org/project/asort/. Even though that package is even less maintained than sort-all, it worked well on first try and even kept comments. I'll have another look at it in time |
|
Welp, asort completely deletes the content of |
harshil21
left a comment
There was a problem hiding this comment.
Looks good to me as a temporary solution. I suggested this package in the ruff issue: astral-sh/ruff#1198 (comment)
I found https://pypi.org/project/sort-all/ and found it really useful for keeping the
__all__variables sorted.Admittedly, it's not the best maintained package, but the core functionality works fine. One downside is that comments in the list will be removed, but so far this doesn't affect us.
I would indeed hope that something similar can be set up for
__slots__.