From ef4a3237289854c746cd9b1376bbd0066d639c62 Mon Sep 17 00:00:00 2001 From: Morgan Courbet Date: Thu, 20 Jul 2017 19:26:03 +0200 Subject: [PATCH] Refactor pre_commit_hooks/mixed_line_ending.py --- pre_commit_hooks/mixed_line_ending.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py index 31e8eda..7be4fc5 100644 --- a/pre_commit_hooks/mixed_line_ending.py +++ b/pre_commit_hooks/mixed_line_ending.py @@ -100,15 +100,11 @@ def _parse_arguments(argv=None): ) args = parser.parse_args(argv) - fix = None - if args.fix == MixedLineEndingOption.NO.opt_name: - fix = MixedLineEndingOption.NO - elif args.fix == MixedLineEndingOption.CRLF.opt_name: - fix = MixedLineEndingOption.CRLF - elif args.fix == MixedLineEndingOption.LF.opt_name: - fix = MixedLineEndingOption.LF - else: - fix = MixedLineEndingOption.AUTO + fix, = ( + member for name, member + in MixedLineEndingOption.__members__.items() + if member.opt_name == args.fix + ) args.verbose = min(args.verbose, 2) severity = VERBOSE_OPTION_TO_LOGGING_SEVERITY.get(args.verbose)