Skip to content

Commit

Permalink
🐛 Fix AttributeError on Windows
Browse files Browse the repository at this point in the history
For some reason the pre-commit hook did not have a parser.prog == 'detect-secrets-hook'.
Fixes Yelp#320.
  • Loading branch information
KevinHock committed Jul 23, 2020
1 parent b5ae43a commit 7704408
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions detect_secrets/core/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ def get_parser_to_add_opt_out_options_to(parser):
:rtype: argparse.ArgumentParser
:returns: argparse.ArgumentParser to pass into PluginOptions
"""
if parser.prog == 'detect-secrets-hook':
return parser

for action in parser._actions: # pragma: no cover (Always returns)
if isinstance(action, argparse._SubParsersAction):
for subparser in action.choices.values():
if subparser.prog.endswith('scan'):
return subparser
# Assume it is the 'detect-secrets-hook' console script
# Relying on parser.prog is too brittle
return parser


class ParserBuilder:
Expand Down

0 comments on commit 7704408

Please sign in to comment.