lint: tidy up code some more, pylint is enforcing

This commit is contained in:
Iain Learmonth 2022-06-17 14:02:10 +01:00
parent 66b3ccc0f0
commit 61564e8c01
17 changed files with 72 additions and 38 deletions

View file

@ -44,12 +44,12 @@ class TerraformAutomation(BaseAutomation):
:param full: include a Terraform refresh in the automation module run
:return: success status and Terraform apply logs
"""
prehook_result = self.tf_prehook()
prehook_result = self.tf_prehook() # pylint: disable=assignment-from-no-return
self.tf_generate()
self.tf_init()
returncode, logs = self.tf_apply(refresh=self.always_refresh or full)
self.tf_posthook(prehook_result=prehook_result)
return True if returncode == 0 else False, logs
return returncode == 0, logs
def tf_apply(self, *,
refresh: bool = True,
@ -60,7 +60,7 @@ class TerraformAutomation(BaseAutomation):
# The following subprocess call takes external input, but is providing
# the argument list as an array such that argument injection would be
# ineffective.
tf = subprocess.run( # nosec
tfcmd = subprocess.run( # nosec
['terraform',
'apply',
'-auto-approve',
@ -71,7 +71,7 @@ class TerraformAutomation(BaseAutomation):
],
cwd=self.working_directory(),
stdout=subprocess.PIPE)
return tf.returncode, tf.stdout.decode('utf-8')
return tfcmd.returncode, tfcmd.stdout.decode('utf-8')
@abstractmethod
def tf_generate(self) -> None:
@ -92,11 +92,11 @@ class TerraformAutomation(BaseAutomation):
def tf_output(self) -> Any:
# The following subprocess call does not take any user input.
tf = subprocess.run( # nosec
tfcmd = subprocess.run( # nosec
['terraform', 'output', '-json'],
cwd=self.working_directory(),
stdout=subprocess.PIPE)
return json.loads(tf.stdout)
return json.loads(tfcmd.stdout)
def tf_plan(self, *,
refresh: bool = True,
@ -105,7 +105,7 @@ class TerraformAutomation(BaseAutomation):
# The following subprocess call takes external input, but is providing
# the argument list as an array such that argument injection would be
# ineffective.
tf = subprocess.run( # nosec
tfcmd = subprocess.run( # nosec
['terraform',
'plan',
'-json',
@ -114,7 +114,7 @@ class TerraformAutomation(BaseAutomation):
f'-lock-timeout={str(lock_timeout)}m',
],
cwd=self.working_directory())
return tf.returncode, tf.stdout.decode('utf-8')
return tfcmd.returncode, tfcmd.stdout.decode('utf-8')
def tf_posthook(self, *, prehook_result: Any = None) -> None:
"""
@ -126,7 +126,6 @@ class TerraformAutomation(BaseAutomation):
:param prehook_result: the returned value of :func:`tf_prehook`
:return: None
"""
pass
def tf_prehook(self) -> Optional[Any]:
"""
@ -138,7 +137,6 @@ class TerraformAutomation(BaseAutomation):
:return: state that is useful to :func:`tf_posthook`, if required
"""
pass
def tf_show(self) -> Any:
# This subprocess call doesn't take any user input.