mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 05:43:06 +00:00
Work on issues found by pylint (#896)
* Look at possibly-used-before-assignment. * Use latest beta releases of ansible-core 2.19 for mypy and pylint. * Look at unsupported-*. * Look at unknown-option-value. * Look at redefined-builtin. * Look at superfluous-parens. * Look at unspecified-encoding. * Adjust to new cryptography version and to ansible-core 2.17's pylint. * Look at super-with-arguments. * Look at no-else-*. * Look at try-except-raise. * Look at inconsistent-return-statements. * Look at redefined-outer-name. * Look at redefined-argument-from-local. * Look at attribute-defined-outside-init. * Look at unused-variable. * Look at protected-access. * Look at raise-missing-from. * Look at arguments-differ. * Look at useless-suppression and use-symbolic-message-instead. * Look at consider-using-dict-items. * Look at consider-using-in. * Look at consider-using-set-comprehension. * Look at consider-using-with. * Look at use-dict-literal.
This commit is contained in:
@@ -25,8 +25,10 @@ class PluginGPGRunner(GPGRunner):
|
||||
if executable is None:
|
||||
try:
|
||||
executable = get_bin_path("gpg")
|
||||
except ValueError:
|
||||
raise GPGError("Cannot find the `gpg` executable on the controller")
|
||||
except ValueError as exc:
|
||||
raise GPGError(
|
||||
"Cannot find the `gpg` executable on the controller"
|
||||
) from exc
|
||||
self.executable = executable
|
||||
self.cwd = cwd
|
||||
|
||||
@@ -45,17 +47,17 @@ class PluginGPGRunner(GPGRunner):
|
||||
Raises a ``GPGError`` in case of errors.
|
||||
"""
|
||||
command = [self.executable] + command
|
||||
p = Popen(
|
||||
with Popen(
|
||||
command, shell=False, cwd=self.cwd, stdin=PIPE, stdout=PIPE, stderr=PIPE
|
||||
)
|
||||
stdout, stderr = p.communicate(input=data)
|
||||
stdout_n = to_native(stdout, errors="surrogate_or_replace")
|
||||
stderr_n = to_native(stderr, errors="surrogate_or_replace")
|
||||
if check_rc and p.returncode != 0:
|
||||
raise GPGError(
|
||||
f'Running {" ".join(command)} yielded return code {p.returncode} with stdout: "{stdout_n}" and stderr: "{stderr_n}")'
|
||||
)
|
||||
return t.cast(int, p.returncode), stdout_n, stderr_n
|
||||
) as p:
|
||||
stdout, stderr = p.communicate(input=data)
|
||||
stdout_n = to_native(stdout, errors="surrogate_or_replace")
|
||||
stderr_n = to_native(stderr, errors="surrogate_or_replace")
|
||||
if check_rc and p.returncode != 0:
|
||||
raise GPGError(
|
||||
f'Running {" ".join(command)} yielded return code {p.returncode} with stdout: "{stdout_n}" and stderr: "{stderr_n}")'
|
||||
)
|
||||
return t.cast(int, p.returncode), stdout_n, stderr_n
|
||||
|
||||
|
||||
__all__ = ("PluginGPGRunner",)
|
||||
|
||||
Reference in New Issue
Block a user