Skip to content

Commit

Permalink
Address linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HCookie committed Oct 16, 2024
1 parent bbbc063 commit 8d0d6d0
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ lint:
isort --settings-file=.github/linters/.isort.cfg .
pylint --rcfile=.github/linters/.python-lint --fail-under=9.0 contributors/*.py
mypy --config-file=.github/linters/.mypy.ini contributors/*.py
black .
black . --line-length 120
4 changes: 3 additions & 1 deletion contributors/contributor_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def is_new_contributor(username: str, returning_contributors: list) -> bool:
return True


def merge_contributors(contributors: list[list[ContributorStats]]) -> list[ContributorStats]:
def merge_contributors(
contributors: list[list[ContributorStats]],
) -> list[ContributorStats]:
"""
Merge contributors with the same username from multiple repositories.
Expand Down
6 changes: 2 additions & 4 deletions contributors/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,14 @@ def get_all_contributors(
all_contributors.append(repo_contributors)

# Check for duplicates and merge when usernames are equal
all_contributors = contributor_stats.merge_contributors(all_contributors)

return all_contributors
return contributor_stats.merge_contributors(all_contributors)


def get_contributors(
repo: github3.repos.Repository,
start_date: str,
end_date: str,
) -> list[contributor_stats.ContributorStats]:
) -> list[contributor_stats.ContributorStats] | None:
"""
Get contributors from a single repository and filter by start end dates if present.
Expand Down
16 changes: 8 additions & 8 deletions contributors/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ class EnvironmentConfig:
Environment Configuration
"""

organization: str
repositories_list: list[str]
organization: str | None
repositories_list: list[str] | None
gh_app_id: int | None
gh_app_installation_id: int | None
gh_app_private_key_bytes: bytes
token: str
ghe: str
start_date: str
end_date: str
sponsor_info: str
link_to_profile: str
sponsor_info: bool
link_to_profile: bool
show_organisations_list: list[str]
filename: str = "contributors"

Expand All @@ -101,9 +101,9 @@ def get_env_vars(
Returns:
EnvironmentConfig:
organization, str:
organization, str | None:
the organization to get contributor information for
repositories_list, List[str]:
repositories_list, List[str] | None:
A list of the repositories to get contributor information for
gh_app_id, int|None:
the GitHub App ID to use for authentication
Expand All @@ -119,9 +119,9 @@ def get_env_vars(
the start date to get contributor information from
end_date, str:
the end date to get contributor information to.
sponsor_info, str:
sponsor_info, bool:
whether to get sponsor information on the contributor
link_to_profile, str:
link_to_profile, bool:
whether to link username to Github profile in markdown output
show_organisations_list, list:
Organisations to show in order of preference
Expand Down
1 change: 0 additions & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from unittest.mock import MagicMock, patch

import github3.github

from contributors import auth


Expand Down
6 changes: 5 additions & 1 deletion tests/test_contributor_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import unittest

from contributors.contributor_stats import ContributorStats, is_new_contributor, merge_contributors
from contributors.contributor_stats import (
ContributorStats,
is_new_contributor,
merge_contributors,
)


class TestContributorStats(unittest.TestCase):
Expand Down
24 changes: 22 additions & 2 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,17 @@ def test_write_to_markdown_with_sponsors(self, mock_file):
person2,
]

write_to_markdown(collaborators, "filename", "2023-01-01", "2023-01-02", None, "org/repo", "true", "true", [])
write_to_markdown(
collaborators,
"filename",
"2023-01-01",
"2023-01-02",
None,
"org/repo",
"true",
"true",
[],
)

mock_file.assert_called_once_with("filename", "w", encoding="utf-8")
mock_file().write.assert_any_call("# Contributors\n\n")
Expand Down Expand Up @@ -136,7 +146,17 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file):
person2,
]

write_to_markdown(collaborators, "filename", "2023-01-01", "2023-01-02", None, "org/repo", "false", "false", [])
write_to_markdown(
collaborators,
"filename",
"2023-01-01",
"2023-01-02",
None,
"org/repo",
"false",
"false",
[],
)

mock_file.assert_called_once_with("filename", "w", encoding="utf-8")
mock_file().write.assert_any_call("# Contributors\n\n")
Expand Down

0 comments on commit 8d0d6d0

Please sign in to comment.