Skip to content

Commit

Permalink
py27 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Loo committed Oct 3, 2019
1 parent 47ec637 commit afc9195
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions detect_secrets/plugins/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,12 @@ def default_options(cls):

@property
def __dict__(self):
return {
output = {
'keyword_exclude': self.keyword_exclude,
**super().__dict__,
}
output.update(super(KeywordDetector, self).__dict__)

return output

def __init__(self, keyword_exclude=None, exclude_lines_regex=None, automaton=None, **kwargs):
super(KeywordDetector, self).__init__(
Expand Down
10 changes: 6 additions & 4 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ def get_list_of_plugins(include=None, exclude=None):
):
continue

output.append({
payload = {
'name': name,
**plugin.default_options,
})
}
payload.update(plugin.default_options)

output.append(payload)

if include:
output.extend(include)
Expand All @@ -53,7 +55,7 @@ def get_plugin_report(extra=None):
"""
:type extra: Dict[str, str]
"""
if not extra:
if not extra: # pragma: no cover
extra = {}

longest_name_length = max([
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
def test_disable_flag_text(name, expected):
class MockPlugin(BasePlugin):
@property
def secret_type(self):
def secret_type(self): # pragma: no cover
return ''

MockPlugin.__name__ = name
MockPlugin.__name__ = str(name)

assert MockPlugin.disable_flag_text == expected

Expand Down
6 changes: 4 additions & 2 deletions tests/pre_commit_hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ def test_baseline_gets_updated(
},
])

assert baseline_written['plugins_used'] == \
sorted(regex_based_plugins, key=lambda x: x['name'])
assert baseline_written['plugins_used'] == sorted(
regex_based_plugins,
key=lambda x: x['name'],
)

def test_writes_new_baseline_if_modified(self):
baseline_string = _create_baseline()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deps = -rrequirements-dev.txt
whitelist_externals = coverage
commands =
coverage erase
coverage run -m pytest tests -v
coverage run -m pytest tests
coverage report --show-missing --include=tests/* --fail-under 100
# This is so that we do not regress unintentionally
coverage report --show-missing --include=detect_secrets/* --omit=detect_secrets/core/audit.py,detect_secrets/core/secrets_collection.py,detect_secrets/main.py,detect_secrets/plugins/common/ini_file_parser.py --fail-under 99
Expand Down

0 comments on commit afc9195

Please sign in to comment.