From d0f843c8d6557d9ef6a965f29e8a33bbab0b7101 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 03:56:59 +0000 Subject: [PATCH 1/3] Update dependency PyGithub to v2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- poetry.lock | 13 ++++++++----- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1a52c91d..d233f3ab 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1489,20 +1489,23 @@ files = [ [[package]] name = "pygithub" -version = "1.59.1" +version = "2.1.1" description = "Use the full Github API v3" optional = false python-versions = ">=3.7" files = [ - {file = "PyGithub-1.59.1-py3-none-any.whl", hash = "sha256:3d87a822e6c868142f0c2c4bf16cce4696b5a7a4d142a7bd160e1bdf75bc54a9"}, - {file = "PyGithub-1.59.1.tar.gz", hash = "sha256:c44e3a121c15bf9d3a5cc98d94c9a047a5132a9b01d22264627f58ade9ddc217"}, + {file = "PyGithub-2.1.1-py3-none-any.whl", hash = "sha256:4b528d5d6f35e991ea5fd3f942f58748f24938805cb7fcf24486546637917337"}, + {file = "PyGithub-2.1.1.tar.gz", hash = "sha256:ecf12c2809c44147bce63b047b3d2e9dac8a41b63e90fcb263c703f64936b97c"}, ] [package.dependencies] -deprecated = "*" +Deprecated = "*" pyjwt = {version = ">=2.4.0", extras = ["crypto"]} pynacl = ">=1.4.0" +python-dateutil = "*" requests = ">=2.14.0" +typing-extensions = ">=4.0.0" +urllib3 = ">=1.26.0" [[package]] name = "pygments" @@ -2552,4 +2555,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.8, <3.12" -content-hash = "3e360e6c15fb98a41328494c0de396ac81ed154713c1f72135b8678f679ce6c7" +content-hash = "7606559236348ef97140d4387f884016c52897ae5cf7e999904ec73592937278" diff --git a/pyproject.toml b/pyproject.toml index e354683c..3a385211 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ pyxdg = "0.28" cruft = "2.15.0" oauthlib = "3.2.2" pyjwt = "2.8.0" -PyGithub = "1.59.1" +PyGithub = "2.1.1" reclass-rs = "0.1.1" [tool.poetry.dev-dependencies] From db779233aa485c9716225bf8cd02ded6356f564f Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Mon, 9 Oct 2023 10:10:29 +0200 Subject: [PATCH 2/3] Update dependency syncer to work with PyGithub v2 The `create_pull()` method got changed to take the PR title and body as keyword arguments. This commit updates the dependency syncer implementation to use the new method format and adjusts the expected POST body to match the PyGithub v2 POST request contents. --- commodore/dependency_syncer.py | 4 ++-- tests/test_dependency_sync.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/commodore/dependency_syncer.py b/commodore/dependency_syncer.py index 087a5fcb..a0a4cce6 100644 --- a/commodore/dependency_syncer.py +++ b/commodore/dependency_syncer.py @@ -218,10 +218,10 @@ def ensure_pr( try: if not has_sync_pr: sync_pr = gr.create_pull( - f"Update from {deptype} template", - pr_body, gr.default_branch, branch_name, + title=f"Update from {deptype} template", + body=pr_body, ) else: sync_pr = [pr for pr in prs if pr.head.ref == branch_name][0] diff --git a/tests/test_dependency_sync.py b/tests/test_dependency_sync.py index e5108061..03bd3f59 100644 --- a/tests/test_dependency_sync.py +++ b/tests/test_dependency_sync.py @@ -167,7 +167,6 @@ def _setup_gh_pr_response(method, pr_body=""): { "title": "Update from package template", "body": pr_body, - "draft": False, "base": "master", "head": "template-sync", } From 9297a28741dba39147565015a8bddb60aeacfed3 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Mon, 9 Oct 2023 10:19:11 +0200 Subject: [PATCH 3/3] Switch to new authentication format for PyGithub PyGithub has deprecated passing the token directly as a positional argument when initializing the client. This commit updates all occurrences to use the new `Github(auth=github.Auth.Token(...))` format. --- commodore/dependency_syncer.py | 2 +- tests/test_dependency_sync.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commodore/dependency_syncer.py b/commodore/dependency_syncer.py index a0a4cce6..bd8100cf 100644 --- a/commodore/dependency_syncer.py +++ b/commodore/dependency_syncer.py @@ -45,7 +45,7 @@ def sync_dependencies( deps = read_dependency_list(dependency_list, depfilter) dep_count = len(deps) - gh = github.Github(config.github_token) + gh = github.Github(auth=github.Auth.Token(config.github_token)) # Keep track of how many PRs we've created to better avoid running into rate limits update_count = 0 for i, dn in enumerate(deps, start=1): diff --git a/tests/test_dependency_sync.py b/tests/test_dependency_sync.py index 03bd3f59..f2e866a9 100644 --- a/tests/test_dependency_sync.py +++ b/tests/test_dependency_sync.py @@ -248,7 +248,7 @@ def test_ensure_pr(tmp_path: Path, config: Config, pr_exists: bool): pname = "projectsyn/package-foo" dependency_syncer.ensure_branch(p, "template-sync") - gh = github.Github(config.github_token) + gh = github.Github(auth=github.Auth.Token(config.github_token)) gr = gh.get_repo(pname) msg = dependency_syncer.ensure_pr( @@ -286,7 +286,7 @@ def test_ensure_pr_no_permission(tmp_path: Path, config: Config, pr_exists: bool pname = "projectsyn/package-foo" dependency_syncer.ensure_branch(p, "template-sync") - gh = github.Github(config.github_token) + gh = github.Github(auth=github.Auth.Token(config.github_token)) gr = gh.get_repo(pname) msg = dependency_syncer.ensure_pr(p, pname, gr, "template-sync", [], "") @@ -323,7 +323,7 @@ def test_ensure_pr_comment(tmp_path: Path, config: Config): pname = "projectsyn/package-foo" dependency_syncer.ensure_branch(p, "template-sync") - gh = github.Github(config.github_token) + gh = github.Github(auth=github.Auth.Token(config.github_token)) gr = gh.get_repo(pname) msg = dependency_syncer.ensure_pr(