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

chore: enable mypy checkdisallow_any_generics#2211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/mypy_step_step
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletionsgitlab/client.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -277,7 +277,7 @@ def from_config(
@classmethod
def merge_config(
cls,
options:dict,
options:Dict[str, Any],
gitlab_id: Optional[str] = None,
config_files: Optional[List[str]] = None,
) -> "Gitlab":
Expand DownExpand Up@@ -330,7 +330,9 @@ def merge_config(
)

@staticmethod
def _merge_auth(options: dict, config: gitlab.config.GitlabConfigParser) -> Tuple:
def _merge_auth(
options: Dict[str, Any], config: gitlab.config.GitlabConfigParser
) -> Tuple[Optional[str], Optional[str], Optional[str]]:
"""
Return a tuple where at most one of 3 token types ever has a value.
Since multiple types of tokens may be present in the environment,
Expand DownExpand Up@@ -822,7 +824,7 @@ def http_get(

def http_head(
self, path: str, query_data: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> requests.structures.CaseInsensitiveDict:
) ->"requests.structures.CaseInsensitiveDict[Any]":
"""Make a HEAD request to the Gitlab server.

Args:
Expand Down
4 changes: 2 additions & 2 deletionsgitlab/mixins.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,7 @@ class HeadMixin(_RestManagerBase):
@exc.on_http_error(exc.GitlabHeadError)
def head(
self, id: Optional[Union[str, int]] = None, **kwargs: Any
) -> requests.structures.CaseInsensitiveDict:
) ->"requests.structures.CaseInsensitiveDict[Any]":
"""Retrieve headers from an endpoint.

Args:
Expand DownExpand Up@@ -622,7 +622,7 @@ class DownloadMixin(_RestObjectBase):
def download(
self,
streamed: bool = False,
action: Optional[Callable] = None,
action: Optional[Callable[[bytes], None]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
8 changes: 4 additions & 4 deletionsgitlab/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ def __call__(self, chunk: Any) -> None:
def response_content(
response: requests.Response,
streamed: bool,
action: Optional[Callable],
action: Optional[Callable[[bytes], None]],
chunk_size: int,
*,
iterator: bool,
Expand All@@ -56,11 +56,11 @@ def response_content(

def _transform_types(
data: Dict[str, Any],
custom_types:dict,
custom_types:Dict[str, Any],
*,
transform_data: bool,
transform_files: Optional[bool] = True,
) -> Tuple[dict, dict]:
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""Copy the data dict with attributes that have custom types and transform them
before being sent to the server.

Expand DownExpand Up@@ -157,7 +157,7 @@ def remove_none_from_dict(data: Dict[str, Any]) -> Dict[str, Any]:
def warn(
message: str,
*,
category: Optional[Type] = None,
category: Optional[Type[Warning]] = None,
source: Optional[Any] = None,
) -> None:
"""This `warnings.warn` wrapper function attempts to show the location causing the
Expand Down
22 changes: 17 additions & 5 deletionsgitlab/v4/cli.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -210,8 +210,16 @@ def do_update(self) -> Dict[str, Any]:
return result


# https://github.com/python/typeshed/issues/7539#issuecomment-1076581049
if TYPE_CHECKING:
_SubparserType = argparse._SubParsersAction[argparse.ArgumentParser]
else:
_SubparserType = Any


def _populate_sub_parser_by_class(
cls: Type[gitlab.base.RESTObject], sub_parser: argparse._SubParsersAction
cls: Type[gitlab.base.RESTObject],
sub_parser: _SubparserType,
) -> None:
mgr_cls_name = f"{cls.__name__}Manager"
mgr_cls = getattr(gitlab.v4.objects, mgr_cls_name)
Expand DownExpand Up@@ -301,9 +309,11 @@ def _populate_sub_parser_by_class(
for action_name in cli.custom_actions[name]:
# NOTE(jlvillal): If we put a function for the `default` value of
# the `get` it will always get called, which will break things.
sub_parser_action = action_parsers.get(action_name)
ifsub_parser_action is None:
action_parser = action_parsers.get(action_name)
ifaction_parser is None:
sub_parser_action = sub_parser.add_parser(action_name)
else:
sub_parser_action = action_parser
# Get the attributes for URL/path construction
if mgr_cls._from_parent_attrs:
for x in mgr_cls._from_parent_attrs:
Expand DownExpand Up@@ -335,9 +345,11 @@ def _populate_sub_parser_by_class(
for action_name in cli.custom_actions[name]:
# NOTE(jlvillal): If we put a function for the `default` value of
# the `get` it will always get called, which will break things.
sub_parser_action = action_parsers.get(action_name)
ifsub_parser_action is None:
action_parser = action_parsers.get(action_name)
ifaction_parser is None:
sub_parser_action = sub_parser.add_parser(action_name)
else:
sub_parser_action = action_parser
if mgr_cls._from_parent_attrs:
for x in mgr_cls._from_parent_attrs:
sub_parser_action.add_argument(
Expand Down
4 changes: 2 additions & 2 deletionsgitlab/v4/objects/artifacts.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,7 @@ def download(
ref_name: str,
job: str,
streamed: bool = False,
action: Optional[Callable] = None,
action: Optional[Callable[[bytes], None]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand DownExpand Up@@ -125,7 +125,7 @@ def raw(
artifact_path: str,
job: str,
streamed: bool = False,
action: Optional[Callable] = None,
action: Optional[Callable[[bytes], None]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
2 changes: 1 addition & 1 deletiongitlab/v4/objects/packages.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,7 +103,7 @@ def download(
package_version: str,
file_name: str,
streamed: bool = False,
action: Optional[Callable] = None,
action: Optional[Callable[[bytes], None]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
2 changes: 1 addition & 1 deletiongitlab/v4/objects/projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -504,7 +504,7 @@ def snapshot(
self,
wiki: bool = False,
streamed: bool = False,
action: Optional[Callable] = None,
action: Optional[Callable[[bytes], None]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
2 changes: 1 addition & 1 deletionpyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ exclude = "build/.*"

# 'strict = true' is equivalent to the following:
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
Expand All@@ -21,7 +22,6 @@ warn_unused_configs = true
warn_unused_ignores = true

# The following need to have changes made to be able to enable them:
# disallow_any_generics = true
# disallow_untyped_calls = true
# no_implicit_optional = true

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp