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

Commitacd9294

Browse files
chore: add type hints to gitlab/utils.py
1 parent0b67ca2 commitacd9294

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎gitlab/utils.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
fromtypingimportAny,Callable,Dict,Optional
1819
fromurllib.parseimporturlparse
1920

21+
importrequests
22+
2023

2124
class_StdoutStream(object):
22-
def__call__(self,chunk):
25+
def__call__(self,chunk)->None:
2326
print(chunk)
2427

2528

26-
defresponse_content(response,streamed,action,chunk_size):
29+
defresponse_content(
30+
response:requests.Response,
31+
streamed:bool,
32+
action:Optional[Callable],
33+
chunk_size:int,
34+
):
2735
ifstreamedisFalse:
2836
returnresponse.content
2937

@@ -35,7 +43,7 @@ def response_content(response, streamed, action, chunk_size):
3543
action(chunk)
3644

3745

38-
defcopy_dict(dest,src):
46+
defcopy_dict(dest:Dict[str,Any],src:Dict[str,Any])->None:
3947
fork,vinsrc.items():
4048
ifisinstance(v,dict):
4149
# Transform dict values to new attributes. For example:
@@ -47,7 +55,7 @@ def copy_dict(dest, src):
4755
dest[k]=v
4856

4957

50-
defclean_str_id(id):
58+
defclean_str_id(id:str)->str:
5159
returnid.replace("/","%2F").replace("#","%23")
5260

5361

@@ -59,11 +67,11 @@ def sanitize_parameters(value):
5967
returnvalue
6068

6169

62-
defsanitized_url(url):
70+
defsanitized_url(url:str)->str:
6371
parsed=urlparse(url)
6472
new_path=parsed.path.replace(".","%2E")
6573
returnparsed._replace(path=new_path).geturl()
6674

6775

68-
defremove_none_from_dict(data):
76+
defremove_none_from_dict(data:Dict[str,Any])->Dict[str,Any]:
6977
return {k:vfork,vindata.items()ifvisnotNone}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp