diff --git a/gitlab/cli.py b/gitlab/cli.py index cad6b6fd5..4159632a6 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -301,7 +301,7 @@ def main() -> None: sys.exit(e) # We only support v4 API at this time if config.api_version not in ("4",): # dead code # pragma: no cover - raise ModuleNotFoundError(name=f"gitlab.v{config.api_version}.cli") + raise ModuleNotFoundError(f"gitlab.v{config.api_version}.cli") # Now we build the entire set of subcommands and do the complete parsing parser = _get_parser() diff --git a/gitlab/client.py b/gitlab/client.py index bba5c1d24..a9bd48f62 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -116,7 +116,7 @@ def __init__( # We only support v4 API at this time if self._api_version not in ("4",): - raise ModuleNotFoundError(name=f"gitlab.v{self._api_version}.objects") + raise ModuleNotFoundError(f"gitlab.v{self._api_version}.objects") # NOTE: We must delay import of gitlab.v4.objects until now or # otherwise it will cause circular import errors import gitlab.v4.objects @@ -209,7 +209,7 @@ def __setstate__(self, state: Dict[str, Any]) -> None: # We only support v4 API at this time if self._api_version not in ("4",): raise ModuleNotFoundError( - name=f"gitlab.v{self._api_version}.objects" + f"gitlab.v{self._api_version}.objects" ) # pragma: no cover, dead code currently # NOTE: We must delay import of gitlab.v4.objects until now or # otherwise it will cause circular import errors diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py index 070f2154d..13fc2d837 100644 --- a/tests/unit/test_gitlab.py +++ b/tests/unit/test_gitlab.py @@ -91,7 +91,7 @@ def test_gitlab_init_with_valid_api_version(): def test_gitlab_init_with_invalid_api_version(): - with pytest.raises(ModuleNotFoundError): + with pytest.raises(ModuleNotFoundError, match="gitlab.v1.objects"): gitlab.Gitlab(api_version="1")