Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add the version of python-gitlab to GitlabError#2093

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
JohnVillalovos wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromjlvillal/version_in_keyerror
Draft
Show file tree
Hide file tree
Changes fromall 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
8 changes: 8 additions & 0 deletionsgitlab/exceptions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,10 @@
import functools
from typing import Any, Callable, cast, Optional, Type, TYPE_CHECKING, TypeVar, Union

from . import _version as _gl_version

_PG_VERSION = f" (python-gitlab version: {_gl_version.__version__})"


class GitlabError(Exception):
def __init__(
Expand All@@ -27,6 +31,10 @@ def __init__(
response_body: Optional[bytes] = None,
) -> None:

if isinstance(error_message, str):
error_message += _PG_VERSION
else:
error_message += bytes(_PG_VERSION, encoding="ascii")
Exception.__init__(self, error_message)
# Http status code
self.response_code = response_code
Expand Down
5 changes: 2 additions & 3 deletionstests/unit/test_cli.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,8 +24,7 @@

import pytest

from gitlab import cli
from gitlab.exceptions import GitlabError
from gitlab import cli, exceptions


@pytest.mark.parametrize(
Expand DownExpand Up@@ -71,7 +70,7 @@ def test_cls_to_gitlab_resource(class_name, expected_gitlab_resource):
"message,error,expected",
[
("foobar", None, "foobar\n"),
("foo", GitlabError("bar"), "foo (bar)\n"),
("foo",exceptions.GitlabError("bar"),f"foo (bar{exceptions._PG_VERSION})\n"),
],
)
def test_die(message, error, expected):
Expand Down
7 changes: 5 additions & 2 deletionstests/unit/test_exceptions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,8 +6,11 @@
@pytest.mark.parametrize(
"kwargs,expected",
[
({"error_message": "foo"}, "foo"),
({"error_message": "foo", "response_code": "400"}, "400: foo"),
({"error_message": "foo"}, f"foo{exceptions._PG_VERSION}"),
(
{"error_message": "foo", "response_code": "400"},
f"400: foo{exceptions._PG_VERSION}",
),
],
)
def test_gitlab_error(kwargs, expected):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp