mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Disallow --unique alongside --ignore-cases in file-contents-sorter
Closes #794: using these flags at the same time results in undefined behavior - the final ordering is not guaranteed as --unique breaks sorting due to passing the contents through a set. NOTE: I added a newline before and after the mutex group to be consistent with other usages of mutex groups (e.g., check_builtin_literals.py) in this repo.
This commit is contained in:
parent
873992cf07
commit
6883485395
2 changed files with 26 additions and 14 deletions
|
|
@ -54,18 +54,21 @@ def sort_file_contents(
|
|||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='+', help='Files to sort')
|
||||
parser.add_argument(
|
||||
|
||||
mutex = parser.add_mutually_exclusive_group(required=False)
|
||||
mutex.add_argument(
|
||||
'--ignore-case',
|
||||
action='store_const',
|
||||
const=bytes.lower,
|
||||
default=None,
|
||||
help='fold lower case to upper case characters',
|
||||
)
|
||||
parser.add_argument(
|
||||
mutex.add_argument(
|
||||
'--unique',
|
||||
action='store_true',
|
||||
help='ensure each line is unique',
|
||||
)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
retv = PASS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue