Skip to content

Commit

Permalink
chore: enable pylint check: "no-self-use"
Browse files Browse the repository at this point in the history
Enable the pylint check "no-self-use" and fix the errors detected.
  • Loading branch information
JohnVillalovos committed Jun 4, 2022
1 parent d0b0811 commit 80aadaf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
11 changes: 7 additions & 4 deletions gitlab/client.py
Expand Up @@ -515,7 +515,8 @@ def _set_auth_info(self) -> None:
self.http_username, self.http_password
)

def enable_debug(self) -> None:
@staticmethod
def enable_debug() -> None:
import logging
from http.client import HTTPConnection # noqa

Expand All @@ -534,7 +535,8 @@ def _get_session_opts(self) -> Dict[str, Any]:
"verify": self.ssl_verify,
}

def _get_base_url(self, url: Optional[str] = None) -> str:
@staticmethod
def _get_base_url(url: Optional[str] = None) -> str:
"""Return the base URL with the trailing slash stripped.
If the URL is a Falsy value, return the default URL.
Returns:
Expand All @@ -558,7 +560,8 @@ def _build_url(self, path: str) -> str:
return path
return f"{self._url}{path}"

def _check_redirects(self, result: requests.Response) -> None:
@staticmethod
def _check_redirects(result: requests.Response) -> None:
# Check the requests history to detect 301/302 redirections.
# If the initial verb is POST or PUT, the redirected request will use a
# GET request, leading to unwanted behaviour.
Expand All @@ -583,8 +586,8 @@ def _check_redirects(self, result: requests.Response) -> None:
)
)

@staticmethod
def _prepare_send_data(
self,
files: Optional[Dict[str, Any]] = None,
post_data: Optional[Union[Dict[str, Any], bytes]] = None,
raw: bool = False,
Expand Down
6 changes: 4 additions & 2 deletions gitlab/types.py
Expand Up @@ -103,10 +103,12 @@ def get_for_api(self) -> str:


class FileAttribute(GitlabAttribute):
def get_file_name(self, attr_name: Optional[str] = None) -> Optional[str]:
@staticmethod
def get_file_name(attr_name: Optional[str] = None) -> Optional[str]:
return attr_name


class ImageAttribute(FileAttribute):
def get_file_name(self, attr_name: Optional[str] = None) -> str:
@staticmethod
def get_file_name(attr_name: Optional[str] = None) -> str:
return f"{attr_name}.png" if attr_name else "image.png"
10 changes: 6 additions & 4 deletions gitlab/v4/cli.py
Expand Up @@ -371,13 +371,14 @@ def get_dict(


class JSONPrinter:
def display(self, d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
@staticmethod
def display(d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
import json # noqa

print(json.dumps(d))

@staticmethod
def display_list(
self,
data: List[Union[str, gitlab.base.RESTObject]],
fields: List[str],
**kwargs: Any,
Expand All @@ -388,7 +389,8 @@ def display_list(


class YAMLPrinter:
def display(self, d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
@staticmethod
def display(d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
try:
import yaml # noqa

Expand All @@ -400,8 +402,8 @@ def display(self, d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
"to use the yaml output feature"
)

@staticmethod
def display_list(
self,
data: List[Union[str, gitlab.base.RESTObject]],
fields: List[str],
**kwargs: Any,
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -57,7 +57,6 @@ disable = [
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"no-self-use",
"protected-access",
"redefined-builtin",
"redefined-outer-name",
Expand Down

0 comments on commit 80aadaf

Please sign in to comment.