Skip to content
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

[Proposal] Rule to keep a collection alpha-sorted. #6175

Closed
tylerlaprade opened this issue Jul 29, 2023 · 3 comments
Closed

[Proposal] Rule to keep a collection alpha-sorted. #6175

tylerlaprade opened this issue Jul 29, 2023 · 3 comments
Labels
needs-decision Awaiting a decision from a maintainer

Comments

@tylerlaprade
Copy link
Contributor

Sometimes we have large dictionaries, enums, or even lists that contain relevant config info, but the order of the elements is not relevant. For example, we have a map from each of our Django models to the relevant basenames. We need to include every model, and it's easier to verify that a model is already included if you know where to look. This can be accomplished by alpa-sorting the keys. My suggestion is for there to be a special comment I can put at the top of the collection which will cause the entries to always be alpha-sorted. Maybe # autosort so that other tools can adopt the convention if they so choose?

@charliermarsh charliermarsh added the needs-decision Awaiting a decision from a maintainer label Aug 14, 2023
@charliermarsh
Copy link
Member

I think this can be collapsed with #1198 which proposes that we support sorting collections based on isort's rules (though that's not fully decided yet).

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2023
@tylerlaprade
Copy link
Contributor Author

Would that apply to all collections? This would potentially break other lists for which the order changes the behavior.

@charliermarsh
Copy link
Member

No, I believe there's a pragma comment to mark such collections (see the linked issue for more).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants