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

Forbid the combination of unique and ignore case options in file_contents_sorter.py #826

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pre_commit_hooks/file_contents_sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def main(argv: Sequence[str] | None = None) -> int:
)
args = parser.parse_args(argv)

if args.ignore_case and args.unique:
print('ERROR: usage of --unique and --ignore-case is unsupported. \
Please update your configuration.')
return FAIL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use backslashes like this -- also this is going to render very strangely

also this behaviour needs to be tested (capsys might help) -- but then again you can probably just make this use argparse's mutually exclusive options


retv = PASS

for arg in args.filenames:
Expand Down
6 changes: 0 additions & 6 deletions tests/file_contents_sorter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
(
b'fee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
PASS,
b'fee\nFie\nFoe\nfum\n',
),
(
b'fee\nfee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
FAIL,
b'fee\nFie\nFoe\nfum\n',
),
Expand Down