Skip to content

Commit 7704408

Browse files
committed
🐛 Fix AttributeError on Windows
For some reason the pre-commit hook did not have a parser.prog == 'detect-secrets-hook'. Fixes #320.
1 parent b5ae43a commit 7704408

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

detect_secrets/core/usage.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ def get_parser_to_add_opt_out_options_to(parser):
104104
:rtype: argparse.ArgumentParser
105105
:returns: argparse.ArgumentParser to pass into PluginOptions
106106
"""
107-
if parser.prog == 'detect-secrets-hook':
108-
return parser
109-
110107
for action in parser._actions: # pragma: no cover (Always returns)
111108
if isinstance(action, argparse._SubParsersAction):
112109
for subparser in action.choices.values():
113110
if subparser.prog.endswith('scan'):
114111
return subparser
112+
# Assume it is the 'detect-secrets-hook' console script
113+
# Relying on parser.prog is too brittle
114+
return parser
115115

116116

117117
class ParserBuilder:

0 commit comments

Comments
 (0)