Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/linters/.isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[settings]
profile = black
known_first_party = auth,cleanowners,env,markdown_writer
2 changes: 1 addition & 1 deletion .github/workflows/super-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install dependencies
run: uv sync --frozen
- name: Lint Code Base
uses: super-linter/super-linter@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0
uses: super-linter/super-linter@2da136927bd4a73596db63044b504547c62cb854 # v9.0.0
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN uv sync --frozen --no-dev --no-editable \

# Add a simple healthcheck to satisfy container scanners
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python3 -c "import os,sys; sys.exit(0 if os.path.exists('/action/workspace/cleanowners.py') else 1)"
CMD ["python3", "-c", "import os,sys; sys.exit(0 if os.path.exists('/action/workspace/cleanowners.py') else 1)"]

ENV PYTHONUNBUFFERED=1
ENV UV_LINK_MODE=copy
Expand Down
11 changes: 5 additions & 6 deletions cleanowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import re
import uuid

from github import GithubException, UnknownObjectException

import auth
import env
from github import GithubException, UnknownObjectException
from markdown_writer import write_step_summary, write_to_markdown


Expand Down Expand Up @@ -252,7 +253,7 @@ def main(): # pragma: no cover
f" Check write permissions."
)
continue
except Exception as e: # pylint: disable=broad-exception-caught
except Exception as e: # noqa: BLE001 # pylint: disable=broad-exception-caught
error_message = str(e)
print(f"Error: {error_message}")
finally:
Expand Down Expand Up @@ -361,9 +362,7 @@ def get_usernames_from_codeowners(codeowners_file_contents, ignore_teams=True):
handle = handle.split()[0]
# Identify team handles by the presence of a slash.
# Ignore teams because non-org members cannot be in a team.
if ignore_teams and "/" not in handle:
usernames.append(handle)
elif not ignore_teams:
if not ignore_teams or "/" not in handle:
usernames.append(handle)
return usernames

Expand Down Expand Up @@ -398,7 +397,7 @@ def commit_changes(
default_branch = repo.default_branch
default_branch_commit = repo.get_git_ref(f"heads/{default_branch}").object.sha
front_matter = "refs/heads/"
branch_name = f"codeowners-{str(uuid.uuid4())}"
branch_name = f"codeowners-{uuid.uuid4()!s}"
repo.create_git_ref(front_matter + branch_name, default_branch_commit)
if create_new:
repo.create_file(
Expand Down
3 changes: 1 addition & 2 deletions markdown_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def write_step_summary(
_write_repos_missing_codeowners(file, repos_missing_codeowners, warning_suffix)
if pull_request_urls:
file.write("## Pull Requests Created :link:\n")
for url in pull_request_urls:
file.write(f"- {url}\n")
file.write("".join(f"- {url}\n" for url in pull_request_urls))
file.write("\n")
if error:
file.write(f"## Error :x:\n\n{error}\n")
3 changes: 2 additions & 1 deletion test_cleanowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from io import StringIO
from unittest.mock import MagicMock, patch

from github import UnknownObjectException

from cleanowners import (
build_default_codeowners,
cleanup_whitespace,
Expand All @@ -16,7 +18,6 @@
print_stats,
remove_username_from_content,
)
from github import UnknownObjectException


class TestCommitChanges(unittest.TestCase):
Expand Down
Loading