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

Commit99f321a

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

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

‎.github/workflows/protocol.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name:'Protocaol'
2+
3+
on:
4+
push:
5+
branches:
6+
-main
7+
paths:
8+
-gitlab/protocols/**
9+
pull_request:
10+
branches:
11+
-main
12+
paths:
13+
-gitlab/protocols/**
14+
15+
jobs:
16+
protocol:
17+
runs-on:ubuntu-latest
18+
steps:
19+
-name:Fail
20+
run:/bin/false

‎gitlab/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
importgitlab.const
1414
importgitlab.exceptions
1515
fromgitlabimporthttp_backends,utils
16+
fromgitlab.protocols.clientimportClient
1617

1718
REDIRECT_MSG= (
1819
"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -28,7 +29,7 @@
2829
)
2930

3031

31-
classGitlab:
32+
classGitlab(Client):
3233

3334
"""Represents a GitLab server connection.
3435

‎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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
importsys
2+
fromabcimportabstractmethod
3+
fromtypingimportAny,Dict,Optional,Union
4+
5+
importrequests
6+
7+
ifsys.version_info>= (3,8):
8+
fromtypingimportProtocol
9+
else:
10+
fromtyping_extensionsimportProtocol
11+
12+
13+
classClient(Protocol):
14+
@abstractmethod
15+
defhttp_request(
16+
self,
17+
verb:str,
18+
path:str,
19+
query_data:Optional[Dict[str,Any]],
20+
post_data:Optional[Union[Dict[str,Any],bytes]],
21+
raw:bool,
22+
streamed:bool,
23+
files:Optional[Dict[str,Any]],
24+
timeout:Optional[float],
25+
obey_rate_limit:bool,
26+
retry_transient_errors:Optional[bool],
27+
max_retries:int,
28+
**kwargs:Any,
29+
)->requests.Response:
30+
...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp