Skip to content

Allow sorting TOML table keys #252

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion language_formatters_pre_commit_hooks/pretty_format_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def pretty_format_toml(argv: typing.Optional[typing.List[str]] = None) -> int:
dest="no_sort",
help="Don't sort keys",
)
parser.add_argument(
"--no-sort-table-keys",
action="store_true",
dest="no_sort_table_keys",
help="Don't sort table keys",
)
args = parser.parse_args(argv)

status = 0
Expand All @@ -62,7 +68,7 @@ def pretty_format_toml(argv: typing.Optional[typing.List[str]] = None) -> int:
inline=True,
block=True,
),
sort_config=SortConfiguration(tables=not args.no_sort, table_keys=not args.no_sort),
sort_config=SortConfiguration(tables=not args.no_sort, table_keys=not args.no_sort_table_keys),
format_config=FormattingConfiguration(
spaces_before_inline_comment=args.inline_comment_spaces,
spaces_indent_inline_array=args.indent,
Expand Down