Skip to content

Commit e19910f

Browse files
committed
fix lint error
1 parent ea1d9c7 commit e19910f

2 files changed

Lines changed: 39 additions & 26 deletions

File tree

community/github/git_api.py

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def get_github_repo_issues(
589589
else:
590590
return None
591591

592+
592593
def get_repo_issues(
593594
repo: str,
594595
assignee_username: str = None,
@@ -598,47 +599,53 @@ def get_repo_issues(
598599
):
599600
"""
600601
Get issues from a GitHub repository with optional filtering.
601-
602+
602603
Args:
603604
repo (str): Repository name in the format 'owner/repo'
604605
assignee_username (str, optional): Filter issues by assignee username.
605606
Special values: '*' (any assigned), 'none' (unassigned)
606607
state (str, optional): Filter issues by state ('open', 'closed', 'all'). Default is 'open'.
607-
created_after (str, optional): ISO 8601 formatted timestamp to filter issues created after this date
608-
created_before (str, optional): ISO 8601 formatted timestamp to filter issues created before this date
609-
608+
created_after (str, optional): ISO 8601 formatted timestamp to filter issues created after
609+
this date
610+
created_before (str, optional): ISO 8601 formatted timestamp to filter issues created
611+
before this date
612+
610613
Returns:
611614
list: List of issue objects from the GitHub API
612615
"""
613616
url = f"{GITHUB_API_URL}/repos/{repo}/issues"
614-
617+
615618
params = {
616619
"state": state,
617620
}
618-
621+
619622
# 处理assignee参数
620623
if assignee_username is not None:
621624
# 如果提供了assignee_username,则使用它
622625
params["assignee"] = assignee_username
623-
626+
624627
# GitHub uses 'since' parameter for created_after
625628
if created_after:
626629
params["since"] = created_after
627-
630+
628631
headers = {
629632
"Authorization": f"token {GITHUB_ACCESS_TOKEN}",
630633
"Accept": "application/vnd.github.v3+json",
631634
}
632-
635+
633636
response = requests.get(url, headers=headers, params=params)
634-
637+
635638
if response.status_code == 200:
636639
issues = response.json()
637-
640+
638641
# Filter by created_before if specified
639642
if created_before:
640-
issues = [issue for issue in issues if issue["created_at"][:len(created_before)] <= created_before]
641-
643+
issues = [
644+
issue
645+
for issue in issues
646+
if issue["created_at"][: len(created_before)] <= created_before
647+
]
648+
642649
return issues
643650
else:
644651
print(f"Failed to get issues: {response.status_code}", file=sys.stderr)
@@ -650,50 +657,52 @@ def get_commit_author():
650657
cmd = ["git", "config", "user.email"]
651658
return subprocess_check_output(cmd).decode("utf-8").strip()
652659

660+
653661
def get_repo_commits(repo: str, author=None, since=None, until=None):
654662
"""
655663
Get commits from a GitHub repository with optional filtering.
656-
664+
657665
Args:
658666
repo (str): Repository name in the format 'owner/repo'
659667
author (str, optional): Filter commits by author
660668
since (str, optional): ISO 8601 formatted timestamp to filter commits after this date
661669
until (str, optional): ISO 8601 formatted timestamp to filter commits before this date
662-
670+
663671
Returns:
664672
list: List of commit objects from the GitHub API
665673
"""
666674
url = f"{GITHUB_API_URL}/repos/{repo}/commits"
667-
675+
668676
params = {}
669677
if author:
670678
params["author"] = author
671679
if since:
672680
params["since"] = since
673681
if until:
674682
params["until"] = until
675-
683+
676684
headers = {
677685
"Authorization": f"token {GITHUB_ACCESS_TOKEN}",
678686
"Accept": "application/vnd.github.v3+json",
679687
}
680-
688+
681689
response = requests.get(url, headers=headers, params=params)
682-
690+
683691
if response.status_code == 200:
684692
return response.json()
685693
else:
686694
print(f"Failed to get commits: {response.status_code}")
687695
print(response.text)
688696
return None
689697

698+
690699
def is_github_repo():
691700
"""
692701
Check if the current repository is a GitHub repository.
693-
702+
694703
Tries to determine if the current git repository is hosted on GitHub by
695704
examining the remote URL.
696-
705+
697706
Returns:
698707
bool: True if the repository is hosted on GitHub, False otherwise.
699708
"""
@@ -702,13 +711,13 @@ def is_github_repo():
702711
result = subprocess_check_output(
703712
["git", "remote", "get-url", "origin"], stderr=subprocess.STDOUT
704713
).strip()
705-
714+
706715
# 将结果从bytes转换为str
707716
repo_url = result.decode("utf-8")
708-
717+
709718
# 检查URL是否包含github.com
710719
is_github = "github.com" in repo_url.lower()
711-
720+
712721
IDEService().ide_logging("debug", f"Repository is GitHub: {is_github}")
713722
return is_github
714723
except subprocess.CalledProcessError as e:
@@ -718,4 +727,4 @@ def is_github_repo():
718727
except FileNotFoundError:
719728
# 如果未找到git命令,可能是没有安装git或者不在PATH中
720729
print("==> File not found...", flush=True)
721-
return None
730+
return None

community/work_report/command.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
if is_github_repo():
99
from community.github.git_api import (
1010
get_commit_author,
11-
get_github_repo as get_repo,
1211
get_repo_commits,
1312
get_repo_issues,
13+
)
14+
from community.github.git_api import (
15+
get_github_repo as get_repo,
16+
)
17+
from community.github.git_api import (
1418
get_github_username as get_username,
1519
)
1620
else:

0 commit comments

Comments
 (0)