Skip to content

Commit

Permalink
Merge pull request #759 from conda-forge/pygithub-auth
Browse files Browse the repository at this point in the history
fix: remove deprecated pygithub calls
  • Loading branch information
beckermr authored Nov 2, 2024
2 parents b31b437 + 1fa0715 commit b411a98
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion conda_forge_webservices/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def issue_comment(org_name, repo_name, issue_num, title, comment, comment_id=Non
# this token has to be that of an actual bot since we use this
# to make a fork
# the bot used does not need admin permissions
gh = github.Github(os.environ["GH_TOKEN"])
gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
repo = gh.get_repo(f"{org_name}/{repo_name}")
default_branch = repo.default_branch
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_comment_same_as_before(self):
"conda-forge", "conda-forge-webservices", PR_number, message_to_post
)

gh = github.Github(os.environ["GH_TOKEN"])
gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
linting_repo = gh.get_user("conda-forge").get_repo("conda-forge-webservices")
pr = linting_repo.get_issue(PR_number)
comments = list(pr.get_comments())
Expand Down
8 changes: 6 additions & 2 deletions conda_forge_webservices/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def get_app_token_for_webservices_only():
)
if token is not None:
try:
APP_TOKEN_RESET_TIME = Github(token).rate_limiting_resettime
APP_TOKEN_RESET_TIME = Github(
auth=Auth.Token(token)
).rate_limiting_resettime
except Exception:
LOGGER.info("")
LOGGER.info("===================================================")
Expand Down Expand Up @@ -236,7 +238,9 @@ def _inject_app_token_into_feedstock(full_name, repo=None, readonly=False):
repo = gh.get_repo(full_name)
try:
repo.create_secret(token_name, token)
reset_times_dict[repo_name] = Github(token).rate_limiting_resettime
reset_times_dict[repo_name] = Github(
auth=Auth.Token(token)
).rate_limiting_resettime
LOGGER.info("")
LOGGER.info("===================================================")
LOGGER.info(
Expand Down
2 changes: 1 addition & 1 deletion conda_forge_webservices/update_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@cache
def get_filter_out_members():
gh = github.Github(os.environ["GH_TOKEN"])
gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
org = gh.get_organization("conda-forge")
teams = ["staged-recipes", "help-r", "r"]
gh_teams = list(org.get_team_by_slug(team) for team in teams)
Expand Down
6 changes: 3 additions & 3 deletions conda_forge_webservices/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _shutdown_thread_pool():

def get_commit_message(full_name, commit):
return (
github.Github(os.environ["GH_TOKEN"])
github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
.get_repo(full_name)
.get_commit(commit)
.commit.message
Expand All @@ -105,7 +105,7 @@ def print_rate_limiting_info_for_token(token):
# spending it and how to better optimize it.

# Get GitHub API Rate Limit usage and total
gh = github.Github(token)
gh = github.Github(auth=github.Auth.Token(token))
gh_api_remaining = gh.get_rate_limit().core.remaining
gh_api_total = gh.get_rate_limit().core.limit

Expand Down Expand Up @@ -547,7 +547,7 @@ def _do_copy(feedstock, outputs, channel, git_sha, comment_on_error, hash_type):
# send for github releases copy
# if False:
# try:
# gh = github.Github(os.environ["GH_TOKEN"])
# gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
# repo = gh.get_repo("conda-forge/repodata-shards")
# for dist in copied:
# if not copied[dist]:
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_cfep13_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

try:
GH = github.Github(os.environ["GH_TOKEN"])
GH = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
except Exception:
GH = None

Expand Down

0 comments on commit b411a98

Please sign in to comment.