Skip to content

Commit 0dda019

Browse files
committed
refactor lookup_user
1 parent 9d2892d commit 0dda019

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

etc/update-contributors.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,21 @@ def norm_name(s: str) -> str:
7676
return s.casefold()
7777

7878

79-
def lookup_user(gh, email, name):
80-
user = (
81-
(gh and name_owner.get(norm_name(gh))) or
82-
(email and email_owner.get(email.casefold())) or
83-
name_owner.get(norm_name(name))
84-
)
79+
def lookup_user(gh_username: str, email: str, name: str) -> dict | None:
80+
if gh_username:
81+
user = name_owner.get(norm_name(gh_username))
82+
elif email:
83+
user = email_owner.get(email.casefold())
84+
else:
85+
user = name_owner.get(norm_name(name))
8586
return user
8687

8788
# helpers to find co authors
8889

8990

90-
def find_author_github_nick(email: str, repos: list[str]) -> str | None:
91+
def find_author_github_nick(email: str, repos: list[str]) -> str:
9192
if not email:
92-
return None
93+
return ""
9394
for r in repos:
9495
commit_hash = git_out(
9596
repo_dir(r),
@@ -109,7 +110,7 @@ def find_author_github_nick(email: str, repos: list[str]) -> str | None:
109110
author = resp.json().get("author")
110111
if author and author.get("login"):
111112
return author["login"]
112-
return None
113+
return ""
113114

114115

115116
def find_coauthor_commit(name: str, email: str, repos: list[str]) -> str:

0 commit comments

Comments
 (0)