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

Commit3feb3b7

Browse files
author
Liora Milbaum
committed
feat: PEP 544 – Protocols: Structural subtyping (static duck typing)
1 parent069c6c3 commit3feb3b7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

‎gitlab/client.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Wrapper for the GitLab API."""
22

3+
from __future__importannotations
4+
35
importos
46
importre
57
importtime
@@ -13,6 +15,7 @@
1315
importgitlab.const
1416
importgitlab.exceptions
1517
fromgitlabimporthttp_backends,utils
18+
fromgitlab.protocols.clientimportClient
1619

1720
REDIRECT_MSG= (
1821
"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -28,7 +31,7 @@
2831
)
2932

3033

31-
classGitlab:
34+
classGitlab(Client):
3235

3336
"""Represents a GitLab server connection.
3437

‎gitlab/protocols/__init__.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Defines protocols
3+
"""

‎gitlab/protocols/client.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fromabcimportabstractmethod
2+
fromtypingimportAny,Dict,Optional,Protocol,Union
3+
4+
importrequests
5+
6+
7+
classClient(Protocol):
8+
@abstractmethod
9+
defhttp_request(
10+
self,
11+
verb:str,
12+
path:str,
13+
query_data:Optional[Dict[str,Any]],
14+
post_data:Optional[Union[Dict[str,Any],bytes]],
15+
raw:bool,
16+
streamed:bool,
17+
files:Optional[Dict[str,Any]],
18+
timeout:Optional[float],
19+
obey_rate_limit:bool,
20+
retry_transient_errors:Optional[bool],
21+
max_retries:int,
22+
**kwargs:Any,
23+
)->requests.Response:
24+
...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp