Skip to content

Commit

Permalink
fix: pygithub misses some unknown object exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Jan 24, 2025
1 parent e03ab42 commit 9fa12b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/scripts/create_feedstocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@
recipe_directory_name = "recipes"


def _test_and_raise_besides_file_not_exists(e: github.GithubException):
if isinstance(e, github.UnknownObjectException):
return
if e.status == 404 and "No object found" in e.data["message"]:
return
raise e


def _register_package_for_feedstock(feedstock, pkg_name, gh):
repo = gh.get_repo("conda-forge/feedstock-outputs")
try:
contents = repo.get_contents(_get_sharded_path(pkg_name))
except github.UnknownObjectException:
except github.GithubException as e:
_test_and_raise_besides_file_not_exists(e)
contents = None

if contents is None:
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/scripts/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
HERE = Path(__file__).parent
ROOT = (HERE / ".." / ".." / "..").absolute()


def _test_and_raise_besides_file_not_exists(e: github.GithubException):
if isinstance(e, github.UnknownObjectException):
return
if e.status == 404 and "No object found" in e.data["message"]:
return
raise e


def _lint_recipes(gh, pr):
lints = defaultdict(list)
hints = defaultdict(list)
Expand Down Expand Up @@ -124,7 +133,8 @@ def _lint_recipes(gh, pr):
break
else:
feedstock_exists = False
except github.UnknownObjectException:
except github.GithubException as e:
_test_and_raise_besides_file_not_exists(e)
feedstock_exists = False

if feedstock_exists and existing_recipe_name == recipe_name:
Expand All @@ -138,8 +148,8 @@ def _lint_recipes(gh, pr):
bio = gh.get_user("bioconda").get_repo("bioconda-recipes")
try:
bio.get_dir_contents(f"recipes/{recipe_name}")
except github.UnknownObjectException:
pass
except github.GithubException as e:
_test_and_raise_besides_file_not_exists(e)
else:
hints[fname].append(
"Recipe with the same name exists in bioconda: "
Expand Down

0 comments on commit 9fa12b7

Please sign in to comment.