From fa9ef1d0192a372c56a172484654c4103463ea7c Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sun, 13 Dec 2020 15:25:08 +0100 Subject: Remove pointless try/except. I don't think we need to check for TypeError here, so that saves us the trouble of testing these lines to appease coverage. --- .../apps/home/tests/mock_github_api_response.json | 7 ------- pydis_site/apps/home/views/home.py | 24 +++++++--------------- 2 files changed, 7 insertions(+), 24 deletions(-) (limited to 'pydis_site') diff --git a/pydis_site/apps/home/tests/mock_github_api_response.json b/pydis_site/apps/home/tests/mock_github_api_response.json index 00f2840d..ddbffed8 100644 --- a/pydis_site/apps/home/tests/mock_github_api_response.json +++ b/pydis_site/apps/home/tests/mock_github_api_response.json @@ -34,13 +34,6 @@ "language": "Python", "forks_count": 31 }, - { - "full_name": "python-discord/sir-lancebot", - "description": 42, - "stargazers_count": "bad types", - "language": ["not", "the", "right", "type"], - "forks_count": "31" - }, { "full_name": "python-discord/sir-lancebot", "description": "test", diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py index 77496121..97253a0c 100644 --- a/pydis_site/apps/home/views/home.py +++ b/pydis_site/apps/home/views/home.py @@ -82,23 +82,13 @@ class HomeView(View): # Create all the repodata records in the database. for api_data in api_repositories.values(): - try: - repo_data = RepositoryMetadata( - repo_name=api_data["full_name"], - description=api_data["description"], - forks=api_data["forks_count"], - stargazers=api_data["stargazers_count"], - language=api_data["language"], - ) - # This error indicates there's something not quite right about the api_data types. - # In that case, just skip this repo. - except TypeError: - log.error( - "Encountered a TypeError while processing RepositoryMetadata " - "from the GitHub API.", - extra=api_data - ) - continue + repo_data = RepositoryMetadata( + repo_name=api_data["full_name"], + description=api_data["description"], + forks=api_data["forks_count"], + stargazers=api_data["stargazers_count"], + language=api_data["language"], + ) repo_data.save() database_repositories.append(repo_data) -- cgit v1.2.3