| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 54dd4c3 commit 24d17b4
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,7 +277,7 @@ def from_config( | |||
| 277 | 277 | @classmethod | |
| 278 | 278 | def merge_config( | |
| 279 | 279 | cls, | |
| 280 | - options: dict, | ||
| 280 | + options: Dict[str, Any], | ||
| 281 | 281 | gitlab_id: Optional[str] = None, | |
| 282 | 282 | config_files: Optional[List[str]] = None, | |
| 283 | 283 | ) -> "Gitlab": | |
@@ -330,7 +330,9 @@ def merge_config( | |||
| 330 | 330 | ) | |
| 331 | 331 | ||
| 332 | 332 | @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]]: | ||
| 334 | 336 | """ | |
| 335 | 337 | Return a tuple where at most one of 3 token types ever has a value. | |
| 336 | 338 | Since multiple types of tokens may be present in the environment, | |
@@ -822,7 +824,7 @@ def http_get( | |||
| 822 | 824 | ||
| 823 | 825 | def http_head( | |
| 824 | 826 | self, path: str, query_data: Optional[Dict[str, Any]] = None, **kwargs: Any | |
| 825 | - ) -> requests.structures.CaseInsensitiveDict: | ||
| 827 | + ) -> "requests.structures.CaseInsensitiveDict[Any]": | ||
| 826 | 828 | """Make a HEAD request to the Gitlab server. | |
| 827 | 829 | ||
| 828 | 830 | Args: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,7 @@ class HeadMixin(_RestManagerBase): | |||
| 73 | 73 | @exc.on_http_error(exc.GitlabHeadError) | |
| 74 | 74 | def head( | |
| 75 | 75 | self, id: Optional[Union[str, int]] = None, **kwargs: Any | |
| 76 | - ) -> requests.structures.CaseInsensitiveDict: | ||
| 76 | + ) -> "requests.structures.CaseInsensitiveDict[Any]": | ||
| 77 | 77 | """Retrieve headers from an endpoint. | |
| 78 | 78 | ||
| 79 | 79 | Args: | |
@@ -622,7 +622,7 @@ class DownloadMixin(_RestObjectBase): | |||
| 622 | 622 | def download( | |
| 623 | 623 | self, | |
| 624 | 624 | streamed: bool = False, | |
| 625 | - action: Optional[Callable] = None, | ||
| 625 | + action: Optional[Callable[[bytes], None]] = None, | ||
| 626 | 626 | chunk_size: int = 1024, | |
| 627 | 627 | *, | |
| 628 | 628 | iterator: bool = False, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,7 @@ def __call__(self, chunk: Any) -> None: | |||
| 34 | 34 | def response_content( | |
| 35 | 35 | response: requests.Response, | |
| 36 | 36 | streamed: bool, | |
| 37 | - action: Optional[Callable], | ||
| 37 | + action: Optional[Callable[[bytes], None]], | ||
| 38 | 38 | chunk_size: int, | |
| 39 | 39 | *, | |
| 40 | 40 | iterator: bool, | |
@@ -56,11 +56,11 @@ def response_content( | |||
| 56 | 56 | ||
| 57 | 57 | def _transform_types( | |
| 58 | 58 | data: Dict[str, Any], | |
| 59 | - custom_types: dict, | ||
| 59 | + custom_types: Dict[str, Any], | ||
| 60 | 60 | *, | |
| 61 | 61 | transform_data: bool, | |
| 62 | 62 | transform_files: Optional[bool] = True, | |
| 63 | - ) -> Tuple[dict, dict]: | ||
| 63 | + ) -> Tuple[Dict[str, Any], Dict[str, Any]]: | ||
| 64 | 64 | """Copy the data dict with attributes that have custom types and transform them | |
| 65 | 65 | before being sent to the server. | |
| 66 | 66 | ||
@@ -157,7 +157,7 @@ def remove_none_from_dict(data: Dict[str, Any]) -> Dict[str, Any]: | |||
| 157 | 157 | def warn( | |
| 158 | 158 | message: str, | |
| 159 | 159 | *, | |
| 160 | - category: Optional[Type] = None, | ||
| 160 | + category: Optional[Type[Warning]] = None, | ||
| 161 | 161 | source: Optional[Any] = None, | |
| 162 | 162 | ) -> None: | |
| 163 | 163 | """This `warnings.warn` wrapper function attempts to show the location causing the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -210,8 +210,16 @@ def do_update(self) -> Dict[str, Any]: | |||
| 210 | 210 | return result | |
| 211 | 211 | ||
| 212 | 212 | ||
| 213 | + # https://github.com/python/typeshed/issues/7539#issuecomment-1076581049 | ||
| 214 | + if TYPE_CHECKING: | ||
| 215 | + _SubparserType = argparse._SubParsersAction[argparse.ArgumentParser] | ||
| 216 | + else: | ||
| 217 | + _SubparserType = Any | ||
| 218 | + | ||
| 219 | + | ||
| 213 | 220 | 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, | ||
| 215 | 223 | ) -> None: | |
| 216 | 224 | mgr_cls_name = f"{cls.__name__}Manager" | |
| 217 | 225 | mgr_cls = getattr(gitlab.v4.objects, mgr_cls_name) | |
@@ -301,9 +309,11 @@ def _populate_sub_parser_by_class( | |||
| 301 | 309 | for action_name in cli.custom_actions[name]: | |
| 302 | 310 | # NOTE(jlvillal): If we put a function for the `default` value of | |
| 303 | 311 | # the `get` it will always get called, which will break things. | |
| 304 | - sub_parser_action = action_parsers.get(action_name) | ||
| 305 | - if sub_parser_action is None: | ||
| 312 | + action_parser = action_parsers.get(action_name) | ||
| 313 | + if action_parser is None: | ||
| 306 | 314 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 315 | + else: | ||
| 316 | + sub_parser_action = action_parser | ||
| 307 | 317 | # Get the attributes for URL/path construction | |
| 308 | 318 | if mgr_cls._from_parent_attrs: | |
| 309 | 319 | for x in mgr_cls._from_parent_attrs: | |
@@ -335,9 +345,11 @@ def _populate_sub_parser_by_class( | |||
| 335 | 345 | for action_name in cli.custom_actions[name]: | |
| 336 | 346 | # NOTE(jlvillal): If we put a function for the `default` value of | |
| 337 | 347 | # the `get` it will always get called, which will break things. | |
| 338 | - sub_parser_action = action_parsers.get(action_name) | ||
| 339 | - if sub_parser_action is None: | ||
| 348 | + action_parser = action_parsers.get(action_name) | ||
| 349 | + if action_parser is None: | ||
| 340 | 350 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 351 | + else: | ||
| 352 | + sub_parser_action = action_parser | ||
| 341 | 353 | if mgr_cls._from_parent_attrs: | |
| 342 | 354 | for x in mgr_cls._from_parent_attrs: | |
| 343 | 355 | sub_parser_action.add_argument( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,7 +75,7 @@ def download( | |||
| 75 | 75 | ref_name: str, | |
| 76 | 76 | job: str, | |
| 77 | 77 | streamed: bool = False, | |
| 78 | - action: Optional[Callable] = None, | ||
| 78 | + action: Optional[Callable[[bytes], None]] = None, | ||
| 79 | 79 | chunk_size: int = 1024, | |
| 80 | 80 | *, | |
| 81 | 81 | iterator: bool = False, | |
@@ -125,7 +125,7 @@ def raw( | |||
| 125 | 125 | artifact_path: str, | |
| 126 | 126 | job: str, | |
| 127 | 127 | streamed: bool = False, | |
| 128 | - action: Optional[Callable] = None, | ||
| 128 | + action: Optional[Callable[[bytes], None]] = None, | ||
| 129 | 129 | chunk_size: int = 1024, | |
| 130 | 130 | *, | |
| 131 | 131 | iterator: bool = False, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,7 +103,7 @@ def download( | |||
| 103 | 103 | package_version: str, | |
| 104 | 104 | file_name: str, | |
| 105 | 105 | streamed: bool = False, | |
| 106 | - action: Optional[Callable] = None, | ||
| 106 | + action: Optional[Callable[[bytes], None]] = None, | ||
| 107 | 107 | chunk_size: int = 1024, | |
| 108 | 108 | *, | |
| 109 | 109 | iterator: bool = False, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,7 +504,7 @@ def snapshot( | |||
| 504 | 504 | self, | |
| 505 | 505 | wiki: bool = False, | |
| 506 | 506 | streamed: bool = False, | |
| 507 | - action: Optional[Callable] = None, | ||
| 507 | + action: Optional[Callable[[bytes], None]] = None, | ||
| 508 | 508 | chunk_size: int = 1024, | |
| 509 | 509 | *, | |
| 510 | 510 | iterator: bool = False, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ exclude = "build/.*" | |||
| 9 | 9 | ||
| 10 | 10 | # 'strict = true' is equivalent to the following: | |
| 11 | 11 | check_untyped_defs = true | |
| 12 | + disallow_any_generics = true | ||
| 12 | 13 | disallow_incomplete_defs = true | |
| 13 | 14 | disallow_subclassing_any = true | |
| 14 | 15 | disallow_untyped_decorators = true | |
@@ -21,7 +22,6 @@ warn_unused_configs = true | |||
| 21 | 22 | warn_unused_ignores = true | |
| 22 | 23 | ||
| 23 | 24 | # The following need to have changes made to be able to enable them: | |
| 24 | - # disallow_any_generics = true | ||
| 25 | 25 | # disallow_untyped_calls = true | |
| 26 | 26 | # no_implicit_optional = true | |
| 27 | 27 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments