Skip to content

Commit 8aed1cc

Browse files
committed
update linting
1 parent b96c210 commit 8aed1cc

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

test/test_tg_all.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ def run_all_plan_output(fixtures_dir):
3636

3737
@pytest.fixture
3838
def plan_foo_output(fixtures_dir):
39-
tg = tftest.TerragruntTest(os.path.join('tg_apply_all', 'foo'), fixtures_dir)
39+
tg = tftest.TerragruntTest(os.path.join(
40+
'tg_apply_all', 'foo'), fixtures_dir)
4041
tg.setup()
4142
return tg.plan(output=True)
4243

4344

4445
@pytest.fixture
4546
def bar_output(fixtures_dir):
46-
tg = tftest.TerragruntTest(os.path.join('tg_apply_all', 'bar'), fixtures_dir)
47+
tg = tftest.TerragruntTest(os.path.join(
48+
'tg_apply_all', 'bar'), fixtures_dir)
4749
tg.setup()
4850
tg.apply(output=False, tg_non_interactive=True)
4951
yield tg.output()

tftest.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def parse_args(init_vars=None, tf_vars=None, targets=None, **kw):
107107
]
108108
for arg in _TG_KV_ARGS:
109109
if kw.get(f"tg_{arg}"):
110-
cmd_args += [f'--terragrunt-{arg.replace("_", "-")}', kw[f"tg_{arg}"]]
110+
cmd_args += [f'--terragrunt-{arg.replace("_", "-")}',
111+
kw[f"tg_{arg}"]]
111112
if kw.get('tg_parallelism'):
112113
cmd_args.append(f'--terragrunt-parallelism {kw["tg_parallelism"]}')
113114
if isinstance(kw.get('tg_override_attr'), dict):
@@ -241,10 +242,8 @@ def __init__(self, raw):
241242
(v['address'], v) for v in self._raw.get('resource_changes', {}))
242243
# there might be no variables defined
243244
self.variables = TerraformValueDict(raw.get('variables', {}))
244-
245-
prior_state = raw.get('prior_state', {})
246-
values = prior_state.get('values', {})
247-
self.prior_root_module = TerraformPlanModule(values.get('root_module', {}))
245+
self.prior_root_module = TerraformPlanModule(
246+
raw.get('prior_state', {}).get('values', {}).get('root_module', {}))
248247

249248
@property
250249
def resources(self):
@@ -337,7 +336,8 @@ def __init__(self, tfdir, basedir=None, binary='terraform', env=None,
337336
self.env = os.environ.copy()
338337
self.tg_run_all = False
339338
self._plan_formatter = lambda out: TerraformPlanOutput(json.loads(out))
340-
self._output_formatter = lambda out: TerraformValueDict(json.loads(out))
339+
self._output_formatter = lambda out: TerraformValueDict(
340+
json.loads(out))
341341
self.enable_cache = enable_cache
342342
if not cache_dir:
343343
self.cache_dir = Path(os.path.dirname(
@@ -372,11 +372,13 @@ def remove_readonly(func, path, excinfo):
372372
for tg_dir in glob.glob(path, recursive=True):
373373
if os.path.isdir(tg_dir):
374374
shutil.rmtree(tg_dir, onerror=remove_readonly)
375-
_LOGGER.debug('Restoring original TF files after prevent destroy changes')
375+
_LOGGER.debug(
376+
'Restoring original TF files after prevent destroy changes')
376377
if restore_files:
377378
for bkp_file in Path(tfdir).rglob('*.bkp'):
378379
try:
379-
shutil.copy(str(bkp_file), f'{str(bkp_file).strip(".bkp")}')
380+
shutil.copy(str(bkp_file),
381+
f'{str(bkp_file).strip(".bkp")}')
380382
except (IOError, OSError):
381383
_LOGGER.exception(
382384
f'Unable to restore terraform file {bkp_file.resolve()}')
@@ -467,7 +469,8 @@ def cache(self, **kwargs):
467469
return func(self, **kwargs)
468470

469471
cache_dir = self.cache_dir / \
470-
Path(sha1(self.tfdir.encode("cp037")).hexdigest()) / Path(func.__name__)
472+
Path(sha1(self.tfdir.encode("cp037")).hexdigest()) / \
473+
Path(func.__name__)
471474
cache_dir.mkdir(parents=True, exist_ok=True)
472475

473476
hash_filename = self.generate_cache_hash(kwargs)
@@ -642,7 +645,8 @@ def plan(self, input=False, color=False, refresh=True, tf_vars=None,
642645
try:
643646
return self._plan_formatter(result.out)
644647
except json.JSONDecodeError as e:
645-
raise TerraformTestError('Error decoding plan output: {}'.format(e))
648+
raise TerraformTestError(
649+
'Error decoding plan output: {}'.format(e))
646650

647651
@_cache
648652
def apply(self, input=False, color=False, auto_approve=True, tf_vars=None,
@@ -715,8 +719,8 @@ def execute_command(self, cmd, *cmd_args):
715719
full_output_lines = []
716720
try:
717721
stderr_mode = subprocess.STDOUT if os.name == 'nt' else subprocess.PIPE
718-
p = subprocess.Popen(cmdline, stdout=subprocess.PIPE,
719-
stderr=stderr_mode, cwd=self.tfdir, env=self.env,
722+
p = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=stderr_mode,
723+
cwd=self.tfdir, env=self.env,
720724
universal_newlines=True, encoding='utf-8',
721725
errors='ignore')
722726
while True:

0 commit comments

Comments
 (0)