Skip to content

Commit

Permalink
style: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-Martin committed Oct 2, 2024
1 parent e75ce9d commit a08a95e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
14 changes: 12 additions & 2 deletions dependabot_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ def build_dependabot_file(
if dependabot_file and dependabot_file[-1] != "\n":
dependabot_file += "\n"
dependabot_file += make_dependabot_config(
manager, group_dependencies, indent, schedule, schedule_day, labels
manager,
group_dependencies,
indent,
schedule,
schedule_day,
labels,
)
break
except github3.exceptions.NotFoundError:
Expand All @@ -167,7 +172,12 @@ def build_dependabot_file(
if file[0].endswith(".tf"):
package_managers_found["terraform"] = True
dependabot_file += make_dependabot_config(
"terraform", group_dependencies, indent, schedule, schedule_day, labels
"terraform",
group_dependencies,
indent,
schedule,
schedule_day,
labels,
)
break
except github3.exceptions.NotFoundError:
Expand Down
6 changes: 2 additions & 4 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ def get_env_vars(
labels_str = os.getenv("LABELS")
labels_list = []
if labels_str:
labels_list = [
label.lower().strip() for label in labels_str.split(",")
]
labels_list = [label.lower().strip() for label in labels_str.split(",")]

return (
organization,
Expand All @@ -358,5 +356,5 @@ def get_env_vars(
repo_specific_exemptions,
schedule,
schedule_day,
labels_list
labels_list,
)
2 changes: 1 addition & 1 deletion evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def main(): # pragma: no cover
existing_config,
schedule,
schedule_day,
labels
labels,
)

if dependabot_file is None:
Expand Down
34 changes: 29 additions & 5 deletions test_dependabot_file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-many-public-methods
"""Tests for the dependabot_file.py functions."""

import unittest
Expand Down Expand Up @@ -411,7 +412,9 @@ def test_build_dependabot_file_with_exempt_ecosystems(self):
repo = MagicMock()
repo.file_contents.side_effect = lambda filename: filename == "Dockerfile"

result = build_dependabot_file(repo, False, ["docker"], {}, None, "weekly", "", [])
result = build_dependabot_file(
repo, False, ["docker"], {}, None, "weekly", "", []
)
self.assertEqual(result, None)

def test_build_dependabot_file_with_repo_specific_exempt_ecosystems(self):
Expand Down Expand Up @@ -487,7 +490,14 @@ def test_build_dependabot_file_for_multiple_repos_with_few_existing_config(self)
interval: 'weekly'
"""
result = build_dependabot_file(
no_existing_config_repo, False, exempt_ecosystems, {}, None, "weekly", "", []
no_existing_config_repo,
False,
exempt_ecosystems,
{},
None,
"weekly",
"",
[],
)
self.assertEqual(result, expected_result)

Expand Down Expand Up @@ -527,11 +537,17 @@ def test_check_multiple_repos_with_no_dependabot_config(self):
interval: 'weekly'
"""
result = build_dependabot_file(
no_existing_config_repo, False, exempt_ecosystems, {}, None, "weekly", "", []
no_existing_config_repo,
False,
exempt_ecosystems,
{},
None,
"weekly",
"",
[],
)
self.assertEqual(result, expected_result)


def test_build_dependabot_file_with_label(self):
"""Test that the dependabot.yml file is built correctly with one label set"""
repo = MagicMock()
Expand Down Expand Up @@ -574,9 +590,17 @@ def test_build_dependabot_file_with_labels(self):
- "test2"
"""
result = build_dependabot_file(
repo, False, [], {}, None, "weekly", "", ["dependencies", "test1", "test2"]
repo,
False,
[],
{},
None,
"weekly",
"",
["dependencies", "test1", "test2"],
)
self.assertEqual(result, expected_result)


if __name__ == "__main__":
unittest.main()
9 changes: 5 additions & 4 deletions test_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=too-many-public-methods
# pylint: disable=too-many-public-methods,too-many-lines

"""Test the get_env_vars function"""

Expand Down Expand Up @@ -933,7 +933,7 @@ def test_get_env_vars_with_valid_schedule_and_schedule_day(self):
{
"ORGANIZATION": "my_organization",
"GH_TOKEN": "my_token",
"LABELS": "dependencies"
"LABELS": "dependencies",
},
clear=True,
)
Expand Down Expand Up @@ -976,7 +976,7 @@ def test_get_env_vars_with_a_valid_label(self):
{
"ORGANIZATION": "my_organization",
"GH_TOKEN": "my_token",
"LABELS": "dependencies, test ,test2 "
"LABELS": "dependencies, test ,test2 ",
},
clear=True,
)
Expand Down Expand Up @@ -1009,10 +1009,11 @@ def test_get_env_vars_with_valid_labels_containing_spaces(self):
{}, # repo_specific_exemptions
"weekly", # schedule
"", # schedule_day
["dependencies", "test" ,"test2"], # labels
["dependencies", "test", "test2"], # labels
)
result = get_env_vars(True)
self.assertEqual(result, expected_result)


if __name__ == "__main__":
unittest.main()

0 comments on commit a08a95e

Please sign in to comment.