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

Commitab9dfe4

Browse files
chore: enable mypy checkdisallow_any_generics
1 parent54dd4c3 commitab9dfe4

File tree

8 files changed

+33
-19
lines changed

8 files changed

+33
-19
lines changed

‎gitlab/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def from_config(
277277
@classmethod
278278
defmerge_config(
279279
cls,
280-
options:dict,
280+
options:Dict[str,Any],
281281
gitlab_id:Optional[str]=None,
282282
config_files:Optional[List[str]]=None,
283283
)->"Gitlab":
@@ -330,7 +330,9 @@ def merge_config(
330330
)
331331

332332
@staticmethod
333-
def_merge_auth(options:dict,config:gitlab.config.GitlabConfigParser)->Tuple:
333+
def_merge_auth(
334+
options:Dict[str,Any],config:gitlab.config.GitlabConfigParser
335+
)->Tuple[Optional[str],Optional[str],Optional[str]]:
334336
"""
335337
Return a tuple where at most one of 3 token types ever has a value.
336338
Since multiple types of tokens may be present in the environment,
@@ -822,7 +824,7 @@ def http_get(
822824

823825
defhttp_head(
824826
self,path:str,query_data:Optional[Dict[str,Any]]=None,**kwargs:Any
825-
)->requests.structures.CaseInsensitiveDict:
827+
)->"requests.structures.CaseInsensitiveDict[Any]":
826828
"""Make a HEAD request to the Gitlab server.
827829
828830
Args:

‎gitlab/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class HeadMixin(_RestManagerBase):
7373
@exc.on_http_error(exc.GitlabHeadError)
7474
defhead(
7575
self,id:Optional[Union[str,int]]=None,**kwargs:Any
76-
)->requests.structures.CaseInsensitiveDict:
76+
)->requests.structures.CaseInsensitiveDict[Any]:
7777
"""Retrieve headers from an endpoint.
7878
7979
Args:
@@ -622,7 +622,7 @@ class DownloadMixin(_RestObjectBase):
622622
defdownload(
623623
self,
624624
streamed:bool=False,
625-
action:Optional[Callable]=None,
625+
action:Optional[Callable[[bytes],None]]=None,
626626
chunk_size:int=1024,
627627
*,
628628
iterator:bool=False,

‎gitlab/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __call__(self, chunk: Any) -> None:
3434
defresponse_content(
3535
response:requests.Response,
3636
streamed:bool,
37-
action:Optional[Callable],
37+
action:Optional[Callable[[bytes],None]],
3838
chunk_size:int,
3939
*,
4040
iterator:bool,
@@ -56,11 +56,11 @@ def response_content(
5656

5757
def_transform_types(
5858
data:Dict[str,Any],
59-
custom_types:dict,
59+
custom_types:Dict[str,Any],
6060
*,
6161
transform_data:bool,
6262
transform_files:Optional[bool]=True,
63-
)->Tuple[dict,dict]:
63+
)->Tuple[Dict[str,Any],Dict[str,Any]]:
6464
"""Copy the data dict with attributes that have custom types and transform them
6565
before being sent to the server.
6666
@@ -157,7 +157,7 @@ def remove_none_from_dict(data: Dict[str, Any]) -> Dict[str, Any]:
157157
defwarn(
158158
message:str,
159159
*,
160-
category:Optional[Type]=None,
160+
category:Optional[Type[Warning]]=None,
161161
source:Optional[Any]=None,
162162
)->None:
163163
"""This `warnings.warn` wrapper function attempts to show the location causing the

‎gitlab/v4/cli.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,16 @@ def do_update(self) -> Dict[str, Any]:
210210
returnresult
211211

212212

213+
# https://github.com/python/typeshed/issues/7539#issuecomment-1076581049
214+
ifTYPE_CHECKING:
215+
_SubparserType=argparse._SubParsersAction[argparse.ArgumentParser]
216+
else:
217+
_SubparserType=Any
218+
219+
213220
def_populate_sub_parser_by_class(
214-
cls:Type[gitlab.base.RESTObject],sub_parser:argparse._SubParsersAction
221+
cls:Type[gitlab.base.RESTObject],
222+
sub_parser:_SubparserType,
215223
)->None:
216224
mgr_cls_name=f"{cls.__name__}Manager"
217225
mgr_cls=getattr(gitlab.v4.objects,mgr_cls_name)
@@ -301,9 +309,11 @@ def _populate_sub_parser_by_class(
301309
foraction_nameincli.custom_actions[name]:
302310
# NOTE(jlvillal): If we put a function for the `default` value of
303311
# the `get` it will always get called, which will break things.
304-
sub_parser_action=action_parsers.get(action_name)
305-
ifsub_parser_actionisNone:
312+
action_parser=action_parsers.get(action_name)
313+
ifaction_parserisNone:
306314
sub_parser_action=sub_parser.add_parser(action_name)
315+
else:
316+
sub_parser_action=action_parser
307317
# Get the attributes for URL/path construction
308318
ifmgr_cls._from_parent_attrs:
309319
forxinmgr_cls._from_parent_attrs:
@@ -335,9 +345,11 @@ def _populate_sub_parser_by_class(
335345
foraction_nameincli.custom_actions[name]:
336346
# NOTE(jlvillal): If we put a function for the `default` value of
337347
# the `get` it will always get called, which will break things.
338-
sub_parser_action=action_parsers.get(action_name)
339-
ifsub_parser_actionisNone:
348+
action_parser=action_parsers.get(action_name)
349+
ifaction_parserisNone:
340350
sub_parser_action=sub_parser.add_parser(action_name)
351+
else:
352+
sub_parser_action=action_parser
341353
ifmgr_cls._from_parent_attrs:
342354
forxinmgr_cls._from_parent_attrs:
343355
sub_parser_action.add_argument(

‎gitlab/v4/objects/artifacts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def download(
7575
ref_name:str,
7676
job:str,
7777
streamed:bool=False,
78-
action:Optional[Callable]=None,
78+
action:Optional[Callable[[bytes],None]]=None,
7979
chunk_size:int=1024,
8080
*,
8181
iterator:bool=False,
@@ -125,7 +125,7 @@ def raw(
125125
artifact_path:str,
126126
job:str,
127127
streamed:bool=False,
128-
action:Optional[Callable]=None,
128+
action:Optional[Callable[[bytes],None]]=None,
129129
chunk_size:int=1024,
130130
*,
131131
iterator:bool=False,

‎gitlab/v4/objects/packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def download(
103103
package_version:str,
104104
file_name:str,
105105
streamed:bool=False,
106-
action:Optional[Callable]=None,
106+
action:Optional[Callable[[bytes],None]]=None,
107107
chunk_size:int=1024,
108108
*,
109109
iterator:bool=False,

‎gitlab/v4/objects/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def snapshot(
504504
self,
505505
wiki:bool=False,
506506
streamed:bool=False,
507-
action:Optional[Callable]=None,
507+
action:Optional[Callable[[bytes],None]]=None,
508508
chunk_size:int=1024,
509509
*,
510510
iterator:bool=False,

‎pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exclude = "build/.*"
99

1010
# 'strict = true' is equivalent to the following:
1111
check_untyped_defs =true
12+
disallow_any_generics =true
1213
disallow_incomplete_defs =true
1314
disallow_subclassing_any =true
1415
disallow_untyped_decorators =true
@@ -21,7 +22,6 @@ warn_unused_configs = true
2122
warn_unused_ignores =true
2223

2324
# The following need to have changes made to be able to enable them:
24-
# disallow_any_generics = true
2525
# disallow_untyped_calls = true
2626
# no_implicit_optional = true
2727

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp