Skip to content

Commit 605bc7b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bde6fab commit 605bc7b

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

plugins/action/git_publish.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ActionModule(GitBase):
6161

6262
# pylint: disable=too-many-arguments
6363
def __init__( # noqa: PLR0913
64-
self: T,
64+
self,
6565
connection: Connection,
6666
loader: DataLoader,
6767
play_context: PlayContext,
@@ -97,7 +97,7 @@ def __init__( # noqa: PLR0913
9797
self._env: Optional[Dict[str, str]] = None
9898
self._temp_ssh_key_path: Optional[str] = None
9999

100-
def _check_argspec(self: T) -> None:
100+
def _check_argspec(self) -> None:
101101
"""Check the argspec for the action plugin.
102102
103103
:raises AnsibleActionFail: If the argspec is invalid
@@ -117,7 +117,7 @@ def _check_argspec(self: T) -> None:
117117
msg = "Parameters `ssh_key_file` and `ssh_key_content` are mutually exclusive."
118118
raise AnsibleActionFail(msg)
119119

120-
def _prepare_ssh_environment(self: T) -> None:
120+
def _prepare_ssh_environment(self) -> None:
121121
"""Prepare the environment for SSH key authentication."""
122122
key_content = self._task.args.get("ssh_key_content")
123123
key_file = self._task.args.get("ssh_key_file")
@@ -137,12 +137,12 @@ def _prepare_ssh_environment(self: T) -> None:
137137
ssh_command = f"ssh -i {key_path} -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
138138
self._env = {"GIT_SSH_COMMAND": ssh_command}
139139

140-
def _cleanup_ssh_key(self: T) -> None:
140+
def _cleanup_ssh_key(self) -> None:
141141
"""Remove the temporary SSH key file if it was created."""
142142
if self._temp_ssh_key_path:
143143
Path(self._temp_ssh_key_path).unlink()
144144

145-
def _configure_git_user_name(self: T) -> None:
145+
def _configure_git_user_name(self) -> None:
146146
"""Configure the git user name."""
147147
command_parts = list(self._base_command)
148148
command_parts.extend(["config", "--get", "user.name"])
@@ -167,7 +167,7 @@ def _configure_git_user_name(self: T) -> None:
167167
self._run_command(command=command)
168168
self._result.user_name = name
169169

170-
def _configure_git_user_email(self: T) -> None:
170+
def _configure_git_user_email(self) -> None:
171171
"""Configure the git user email."""
172172
command_parts = list(self._base_command)
173173
command_parts.extend(["config", "--get", "user.email"])
@@ -192,7 +192,7 @@ def _configure_git_user_email(self: T) -> None:
192192
self._run_command(command=command)
193193
self._result.user_email = email
194194

195-
def _add(self: T) -> None:
195+
def _add(self) -> None:
196196
"""Add files for the pending commit."""
197197
command_parts = list(self._base_command)
198198
files = " ".join(self._task.args["include"])
@@ -204,7 +204,7 @@ def _add(self: T) -> None:
204204
)
205205
self._run_command(command=command)
206206

207-
def _commit(self: T) -> None:
207+
def _commit(self) -> None:
208208
"""Perform a commit for the pending push."""
209209
command_parts = list(self._base_command)
210210
message = self._task.args["commit"]["message"].format(play_name=self._play_name)
@@ -217,7 +217,7 @@ def _commit(self: T) -> None:
217217
)
218218
self._run_command(command=command)
219219

220-
def _tag(self: T) -> None:
220+
def _tag(self) -> None:
221221
"""Create a tag object."""
222222
command_parts = list(self._base_command)
223223
message = self._task.args["tag"].get("message")
@@ -233,7 +233,7 @@ def _tag(self: T) -> None:
233233
)
234234
self._run_command(command=command)
235235

236-
def _push(self: T) -> None:
236+
def _push(self) -> None:
237237
"""Push the commit to the origin."""
238238
command_parts = list(self._base_command)
239239
command_parts.extend(["remote", "-v"])
@@ -278,7 +278,7 @@ def _push(self: T) -> None:
278278
line for line in command.stderr.split("remote:") if "https" in line
279279
).strip()
280280

281-
def _remove_repo(self: T) -> None:
281+
def _remove_repo(self) -> None:
282282
"""Remove the temporary directory."""
283283
if not self._task.args["remove"]:
284284
return
@@ -290,7 +290,7 @@ def _remove_repo(self: T) -> None:
290290
self._result.msg = "Failed to remove repository"
291291

292292
def run(
293-
self: T,
293+
self,
294294
tmp: None = None,
295295
task_vars: Optional[Dict[str, JSONTypes]] = None,
296296
) -> Dict[str, JSONTypes]:

plugins/action/git_retrieve.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ActionModule(GitBase):
6262
_requires_connection = False
6363

6464
def __init__( # noqa: PLR0913
65-
self: T,
65+
self,
6666
connection: Connection,
6767
loader: DataLoader,
6868
play_context: PlayContext,
@@ -101,7 +101,7 @@ def __init__( # noqa: PLR0913
101101
self._temp_ssh_key_path: Optional[str] = None
102102
self._ssh_command_str: str = "ssh"
103103

104-
def _check_argspec(self: T) -> None:
104+
def _check_argspec(self) -> None:
105105
"""Check the argspec for the action plugin.
106106
107107
:raises AnsibleActionFail: If the argspec is invalid
@@ -129,7 +129,7 @@ def _check_argspec(self: T) -> None:
129129
)
130130
raise AnsibleActionFail(msg)
131131

132-
def _prepare_ssh_environment(self: T) -> None:
132+
def _prepare_ssh_environment(self) -> None:
133133
"""Prepare the environment for SSH key authentication."""
134134
origin_args = self._task.args.get("origin", {})
135135
key_content = origin_args.get("ssh_key_content")
@@ -151,20 +151,20 @@ def _prepare_ssh_environment(self: T) -> None:
151151
f"ssh -i {key_path} -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
152152
)
153153

154-
def _cleanup_ssh_key(self: T) -> None:
154+
def _cleanup_ssh_key(self) -> None:
155155
"""Remove the temporary SSH key file if it was created."""
156156
if self._temp_ssh_key_path:
157157
Path(self._temp_ssh_key_path).unlink()
158158

159159
@property
160-
def _branch_exists(self: T) -> bool:
160+
def _branch_exists(self) -> bool:
161161
"""Return True if the branch exists.
162162
163163
:returns: True if the branch exists
164164
"""
165165
return self._branch_name in self._branches
166166

167-
def _host_key_checking(self: T) -> None:
167+
def _host_key_checking(self) -> None:
168168
"""Configure host key checking."""
169169
origin = self._task.args["origin"]["url"]
170170
upstream = self._task.args["upstream"].get("url") or ""
@@ -188,7 +188,7 @@ def _host_key_checking(self: T) -> None:
188188
)
189189
self._run_command(command=command)
190190

191-
def _clone(self: T) -> None:
191+
def _clone(self) -> None:
192192
"""Clone the repository, creating a new subdirectory."""
193193
origin = self._task.args["origin"]["url"]
194194
upstream = self._task.args["upstream"].get("url") or ""
@@ -247,7 +247,7 @@ def _clone(self: T) -> None:
247247
self._base_command = ("git", "-C", self._repo_path)
248248
return
249249

250-
def _get_branches(self: T) -> None:
250+
def _get_branches(self) -> None:
251251
"""Get the branches."""
252252
command_parts = list(self._base_command)
253253
command_parts.extend(["branch", "-a"])
@@ -294,14 +294,14 @@ def _get_branches(self: T) -> None:
294294
self._result.branch_name = self._branch_name
295295
return
296296

297-
def _detect_duplicate_branch(self: T) -> None:
297+
def _detect_duplicate_branch(self) -> None:
298298
"""Detect duplicate branch."""
299299
duplicate_detection = self._task.args["branch"]["duplicate_detection"]
300300
if duplicate_detection and self._branch_exists:
301301
self._result.failed = True
302302
self._result.msg = f"Branch '{self._branch_name}' already exists"
303303

304-
def _switch_checkout(self: T) -> None:
304+
def _switch_checkout(self) -> None:
305305
"""Switch to or checkout the branch."""
306306
command_parts = list(self._base_command)
307307
branch = self._branch_name
@@ -321,7 +321,7 @@ def _switch_checkout(self: T) -> None:
321321
)
322322
self._run_command(command=command)
323323

324-
def _add_upstream_remote(self: T) -> None:
324+
def _add_upstream_remote(self) -> None:
325325
"""Add the upstream remote."""
326326
if not self._task.args["upstream"].get("url"):
327327
return
@@ -336,7 +336,7 @@ def _add_upstream_remote(self: T) -> None:
336336
self._run_command(command=command)
337337
return
338338

339-
def _pull_upstream(self: T) -> None:
339+
def _pull_upstream(self) -> None:
340340
"""Pull from upstream."""
341341
if not self._task.args["upstream"].get("url"):
342342
return
@@ -363,7 +363,7 @@ def _pull_upstream(self: T) -> None:
363363
return
364364

365365
def run(
366-
self: T,
366+
self,
367367
tmp: None = None,
368368
task_vars: Optional[Dict[str, JSONTypes]] = None,
369369
) -> Dict[str, JSONTypes]:

plugins/plugin_utils/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class Command:
3939
stderr_lines: List[str] = field(default_factory=list)
4040

4141
@property
42-
def command(self: T) -> str:
42+
def command(self) -> str:
4343
"""Return the command as a string.
4444
4545
:return: The command as a string.
4646
"""
4747
return shlex.join(self.command_parts)
4848

4949
@property
50-
def cleaned(self: T) -> Dict[str, Union[int, Dict[str, str], List[str], str]]:
50+
def cleaned(self) -> Dict[str, Union[int, Dict[str, str], List[str], str]]:
5151
"""Return the sanitized details of the command for the log.
5252
5353
:return: The sanitized details of the command for the log.

plugins/plugin_utils/git_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ActionInit:
4444

4545
@property
4646
def asdict(
47-
self: T,
47+
self,
4848
) -> Dict[str, Union[Connection, DataLoader, PlayContext, ModuleType, Task, Templar]]:
4949
"""Create a dictionary, avoiding the deepcopy with dataclass.asdict.
5050
@@ -71,7 +71,7 @@ class ResultBase:
7171
class GitBase(ActionBase): # type: ignore[misc] # parent has type Any
7272
"""Base class for the git paction plugins."""
7373

74-
def __init__(self: U, action_init: ActionInit) -> None:
74+
def __init__(self, action_init: ActionInit) -> None:
7575
"""Initialize the action plugin.
7676
7777
:param action_init: The keyword arguments for action base
@@ -97,7 +97,7 @@ def _git_auth_header(token: str) -> Tuple[str, List[str]]:
9797
]
9898
return basic_encoded, cli_parameters
9999

100-
def _run_command(self: U, command: Command, ignore_errors: bool = False) -> None:
100+
def _run_command(self, command: Command, ignore_errors: bool = False) -> None:
101101
"""Run a command and append the command result to the results.
102102
103103
:param command: The command to run

tests/unit/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .definitions import ActionModuleInit
2121

2222

23-
@pytest.fixture()
23+
@pytest.fixture
2424
def action_init() -> ActionModuleInit:
2525
"""Provide a fixture for action initialization.
2626

0 commit comments

Comments
 (0)