-
Notifications
You must be signed in to change notification settings - Fork 17
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
Option to selectively disable sorting for an entry in an array or whole array #43
Comments
I like the idea of a comment and I'm planning on working on #42. Using a configuration item seems like it would be hard to specify what the rule applies to, while a comment is very clear and a well established pattern for Python tools (flake8, mypy, etc.). What do you think of using With the comment, you could write: [tool.coverage]
paths.source = [
"src", # toml-sort: pin
".tox*/*/lib/python*/site-packages",
] And in my case: [tool.poetry.dependencies]
python = "^3.11" # toml-sort: pin
antigravity = "^0.1" The relative order of pins to eachother would be preserved and they would always be moved to the top: [tool.coverage]
paths.source = [
".tox*/*/lib/python*/site-packages",
"src", # toml-sort: pin
"another", # toml-sort: pin
] Where [tool.coverage]
paths.source = [
"src", # toml-sort: pin
"another", # toml-sort: pin
".tox*/*/lib/python*/site-packages",
] vs. without the comments: [tool.coverage]
paths.source = [
".tox*/*/lib/python*/site-packages",
"another",
"src",
] To selectively ignore an entire array, maybe we could add another type of comment code: [tool.coverage]
paths.source = [ # toml-sort: no-sort
".tox*/*/lib/python*/site-packages",
"src",
"another",
] Any opinions on this approach? Is this the desired behavior? |
I've thought about doing something like this by allowing config overrides either per key or per table. Something like this might work for config file syntax: [tool.tomlsort.overrides]
tool.coverage.sort_inline_arrays = false Where I think that would provide a lot of flexibility when specific tables need different sort options. |
This looks like a great solution! |
That would be really cool, but I sense a bit harder to implement than the comment option? I guess in my case I'd really be looking for |
I almost think we might want both options:
Maybe the new logic in
Maybe we could borrow the concept of [tool.tomlsort.overrides]
no_sort = ["tool.coverage.paths.source"]
[tool.tomlsort.overrides.sort_first]
tool.poetry.dependencies = ["python"] The benefit of a more general [tool.tomlsort.overrides]
no_sort = ["tool.poetry.dependencies"] And with [tool.tomlsort.sort_first]
tool.coverage.paths.source = ["src", "another"] |
My particular use case can be solved by:
😁 cheers! |
It would be great to have the ability to selectively disable sorting for an array (via a comment or a flag in the config). I think the sorting feature is great, but I can only solve this by disabling it for all files, like in #37.
For example, with Coverage for the following to work
src
must appear before the.tox
line, but sorting will change it.The text was updated successfully, but these errors were encountered: