Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle None gracefully in repository topics #4738

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions jobserver/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,11 @@ def get_repos_with_branches(self, org):

topics = []
if repo["repositoryTopics"]["nodes"]:
topics = [n["topic"]["name"] for n in repo["repositoryTopics"]["nodes"]]
topics = [
n["topic"]["name"]
for n in repo["repositoryTopics"]["nodes"]
if n is not None
]

if "non-research" in topics:
continue # Ignore non-research repos.
Expand Down Expand Up @@ -661,7 +665,11 @@ def get_repos_with_dates(self, org):

topics = []
if repo["repositoryTopics"]["nodes"]:
topics = [n["topic"]["name"] for n in repo["repositoryTopics"]["nodes"]]
topics = [
n["topic"]["name"]
for n in repo["repositoryTopics"]["nodes"]
if n is not None
]

yield {
"name": repo["name"],
Expand Down
14 changes: 8 additions & 6 deletions tests/verification/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class TestFakeGitHubAPIWithErrors:
def test_public_methods_raise_githuberror(self):
fake = FakeGitHubAPIWithErrors
for name, method in inspect.getmembers(fake, predicate=inspect.isfunction):
if not name.startswith("_"):
sig = inspect.signature(method)
args = {param.name: None for param in sig.parameters.values()}

with pytest.raises(GitHubError):
method(**args)
assert not name.startswith(
"_"
), "if private methods are ever added to the fake, this assert should be a conditional check instead"
sig = inspect.signature(method)
args = {param.name: None for param in sig.parameters.values()}

with pytest.raises(GitHubError):
method(**args)


@pytest.fixture
Expand Down