codecov-io: # [Codecov](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=h1) Report
> Merging [#202](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=desc) into [master](https://codecov.io/gh/repobee/repobee/commit/aa6378f691bd96d39bb4f8d307368654a0e065fe?src=pr&el=desc) will **decrease** coverage by `0.17%`.
> The diff coverage is `85.71%`.

[![Impacted file tree graph](https://codecov.io/gh/repobee/repobee/pull/202/graphs/tree.svg?width=650&token=5vOKgkphZe&height=150&src=pr)](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #202      +/-   ##
==========================================
- Coverage   92.89%   92.72%   -0.18%     
==========================================
  Files          18       18              
  Lines        1183     1182       -1     
  Branches      203      203              
==========================================
- Hits         1099     1096       -3     
- Misses         68       70       +2     
  Partials       16       16
```


| [Impacted Files](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [repobee/cli.py](https://codecov.io/gh/repobee/repobee/pull/202/diff?src=pr&el=tree#diff-cmVwb2JlZS9jbGkucHk=) | `97.4% <ø> (-0.87%)` | :arrow_down: |
| [repobee/exception.py](https://codecov.io/gh/repobee/repobee/pull/202/diff?src=pr&el=tree#diff-cmVwb2JlZS9leGNlcHRpb24ucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [repobee/github\_api.py](https://codecov.io/gh/repobee/repobee/pull/202/diff?src=pr&el=tree#diff-cmVwb2JlZS9naXRodWJfYXBpLnB5) | `92.4% <50%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=footer). Last update [aa6378f...2674993](https://codecov.io/gh/repobee/repobee/pull/202?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/repobee/cli.py b/repobee/cli.py
index b63c37b..d54ea61 100644
--- a/repobee/cli.py
+++ b/repobee/cli.py
@@ -760,7 +760,6 @@ def _create_base_parsers():
 
 @contextmanager
 def _sys_exit_on_expected_error():
-    """Expect either git.GitError or github_api.APIError."""
     try:
         yield
     except exception.PushFailedError as exc:
diff --git a/repobee/exception.py b/repobee/exception.py
index 15e6e06..6b1163e 100644
--- a/repobee/exception.py
+++ b/repobee/exception.py
@@ -40,7 +40,7 @@ class FileError(RepoBeeException):
     """Raise when reading or writing to a file errors out."""
 
 
-class GitHubError(RepoBeeException):
+class APIError(RepoBeeException):
     """An exception raised when the API responds with an error code."""
 
     def __init__(self, msg="", status=None):
@@ -48,30 +48,24 @@ class GitHubError(RepoBeeException):
         self.status = status
 
 
-class NotFoundError(GitHubError):
+class NotFoundError(APIError):
     """An exception raised when the API responds with a 404."""
 
 
-class ServiceNotFoundError(GitHubError):
+class ServiceNotFoundError(APIError):
     """Raise if the base url can't be located."""
 
 
-class BadCredentials(GitHubError):
+class BadCredentials(APIError):
     """Raise when credentials are rejected."""
 
 
-class UnexpectedException(GitHubError):
+class UnexpectedException(APIError):
     """An exception raised when an API request raises an unexpected
     exception.
     """
 
 
-class APIError(RepoBeeException):
-    """Raise when something unexpected happens when interacting with the
-    API.
-    """
-
-
 class GitError(RepoBeeException):
     """A generic error to raise when a git command exits with a non-zero exit
     status.
diff --git a/repobee/github_api.py b/repobee/github_api.py
index a1d4585..5089d7e 100644
--- a/repobee/github_api.py
+++ b/repobee/github_api.py
@@ -67,7 +67,7 @@ def _try_api_request(ignore_statuses: Optional[Iterable[int]] = None):
     Raises:
         exception.NotFoundError
         exception.BadCredentials
-        exception.GitHubError
+        exception.APIError
         exception.ServiceNotFoundError
         exception.UnexpectedException
     """
@@ -85,7 +85,7 @@ def _try_api_request(ignore_statuses: Optional[Iterable[int]] = None):
                 status=401,
             )
         else:
-            raise exception.GitHubError(str(e), status=e.status)
+            raise exception.APIError(str(e), status=e.status)
     except gaierror:
         raise exception.ServiceNotFoundError(
             "GitHub service could not be found, check the url"
@@ -191,7 +191,7 @@ class GitHubAPI(apimeta.API):
                 existing_users.append(self._github.get_user(name))
             except github.GithubException as exc:
                 if exc.status != 404:
-                    raise exception.GitHubError(
+                    raise exception.APIError(
                         "Got unexpected response code from the GitHub API",
                         status=exc.status,
                     )

Generalize exception.GitHubError to exception.APIError
Such that it makes sense for both GitLab and GitHub. Probably don't need to change any of the internals other than class names.
diff --git a/tests/test_github_api.py b/tests/test_github_api.py
index 9976d19..df8729b 100644
--- a/tests/test_github_api.py
+++ b/tests/test_github_api.py
@@ -338,9 +338,9 @@ class TestEnsureTeamsAndMembers:
     @pytest.mark.parametrize(
         "unexpected_exc",
         [
-            exception.GitHubError("", 404),
-            exception.GitHubError("", 400),
-            exception.GitHubError("", 500),
+            exception.APIError("", 404),
+            exception.APIError("", 400),
+            exception.APIError("", 500),
         ],
     )
     def test_raises_on_non_422_exception(
@@ -421,7 +421,7 @@ class TestCreateRepos:
         side_effect_github_exception = [unexpected_exception] + side_effect[1:]
 
         create_repo_mock.side_effect = side_effect_github_exception
-        with pytest.raises(exception.GitHubError):
+        with pytest.raises(exception.APIError):
             api.create_repos(repo_infos)
 
     def test_returns_all_urls(self, mocker, repos, repo_infos, api):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.4
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
colored==2.3.0
coverage==7.8.0
cryptography==44.0.2
daiquiri==3.2.5.1
Deprecated==1.2.18
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pycparser==2.22
PyGithub==2.6.1
PyJWT==2.10.1
PyNaCl==1.5.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
python-json-logger==3.3.0
-e git+https://github.com/repobee/repobee.git@aa6378f691bd96d39bb4f8d307368654a0e065fe#egg=repobee
repobee-plug==0.5.1
requests==2.32.3
tomli==2.2.1
typing_extensions==4.13.0
urllib3==2.3.0
wrapt==1.17.2

name: repobee
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.4
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - colored==2.3.0
      - coverage==7.8.0
      - cryptography==44.0.2
      - daiquiri==3.2.5.1
      - deprecated==1.2.18
      - exceptiongroup==1.2.2
      - idna==3.10
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycparser==2.22
      - pygithub==2.6.1
      - pyjwt==2.10.1
      - pynacl==1.5.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - python-json-logger==3.3.0
      - repobee==1.4.0
      - repobee-plug==0.5.1
      - requests==2.32.3
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - wrapt==1.17.2
prefix: /opt/conda/envs/repobee

tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception0] tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception1] tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception2]
tests/test_github_api.py::TestEnsureTeamsAndMembers::test_no_previous_teams tests/test_github_api.py::TestEnsureTeamsAndMembers::test_all_teams_exist_but_without_members tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc0] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc1] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc2] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_running_twice_has_no_ill_effects tests/test_github_api.py::TestCreateRepos::test_creates_correct_repos tests/test_github_api.py::TestCreateRepos::test_skips_existing_repos tests/test_github_api.py::TestCreateRepos::test_returns_all_urls tests/test_github_api.py::TestCreateRepos::test_create_repos_without_team_id tests/test_github_api.py::TestGetRepoUrls::test_with_token_without_user tests/test_github_api.py::TestGetRepoUrls::test_with_token_and_user tests/test_github_api.py::TestGetRepoUrls::test_with_students tests/test_github_api.py::TestOpenIssue::test_on_existing_repos tests/test_github_api.py::TestOpenIssue::test_on_some_non_existing_repos tests/test_github_api.py::TestOpenIssue::test_no_crash_when_no_repos_are_found tests/test_github_api.py::TestCloseIssue::test_closes_correct_issues tests/test_github_api.py::TestCloseIssue::test_no_crash_if_no_repos_found tests/test_github_api.py::TestCloseIssue::test_no_crash_if_no_issues_found tests/test_github_api.py::TestGetIssues::test_get_all_open_issues tests/test_github_api.py::TestGetIssues::test_get_all_closed_issues tests/test_github_api.py::TestGetIssues::test_get_issues_when_one_repo_doesnt_exist tests/test_github_api.py::TestGetIssues::test_get_open_issues_by_regex tests/test_github_api.py::TestAddReposToReviewTeams::test_with_default_issue tests/test_github_api.py::TestAddReposToTeams::test_happy_path tests/test_github_api.py::TestDeleteTeams::test_delete_non_existing_teams_does_not_crash tests/test_github_api.py::TestDeleteTeams::test_delete_existing_teams tests/test_github_api.py::TestVerifySettings::test_happy_path tests/test_github_api.py::TestVerifySettings::test_empty_token_raises_bad_credentials tests/test_github_api.py::TestVerifySettings::test_incorrect_info_raises_not_found_error[get_user] tests/test_github_api.py::TestVerifySettings::test_incorrect_info_raises_not_found_error[get_organization] tests/test_github_api.py::TestVerifySettings::test_bad_token_scope_raises tests/test_github_api.py::TestVerifySettings::test_not_owner_raises tests/test_github_api.py::TestVerifySettings::test_raises_unexpected_exception_on_unexpected_status tests/test_github_api.py::TestVerifySettings::test_none_user_raises tests/test_github_api.py::TestVerifySettings::test_mismatching_user_login_raises tests/test_github_api.py::TestGetPeerReviewProgress::test_nothing_returns tests/test_github_api.py::TestGetPeerReviewProgress::test_with_review_teams_but_no_repos
repobee/cli.py repobee/exception.py repobee/github_api.py
repobee/cli.py repobee/exception.py repobee/github_api.py