Skip to content

Commit b342f09

Browse files
author
Alan Christie
committed
More lint fixes
1 parent d520b12 commit b342f09

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

jote/jote.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ def _print_test_banner(collection: str,
3636
print(f'+ collection={collection} job={job_name} test={job_test_name}')
3737

3838

39-
def _lint(definition_file: str) -> bool:
39+
def _lint(definition_filename: str) -> bool:
4040
"""Lints the provided job definition file.
4141
"""
4242

4343
if not os.path.isfile(_YAMLLINT_FILE):
4444
print(f'! The yamllint file ({_YAMLLINT_FILE}) is missing')
4545
return False
4646

47-
errors = linter.run(open(definition_file, encoding='UTF-8'),
48-
YamlLintConfig(file=_YAMLLINT_FILE))
47+
with open(definition_filename, 'rt', encoding='UTF-8') as definition_file:
48+
errors = linter.run(definition_file,
49+
YamlLintConfig(file=_YAMLLINT_FILE))
50+
4951
if errors:
5052
# We're given a 'generator' and we don't know if there are errors
5153
# until we iterator over it. So here we print an initial error message
@@ -171,8 +173,9 @@ def _check_exists(name: str, path: str, expected: bool) -> bool:
171173
def _check_line_count(name: str, path: str, expected: int) -> bool:
172174

173175
line_count: int = 0
174-
for _ in open(path, encoding='UTF-8'):
175-
line_count += 1
176+
with open(path, 'rt', encoding='UTF-8') as check_file:
177+
for _ in check_file:
178+
line_count += 1
176179

177180
if line_count != expected:
178181
print(f'# lineCount ({line_count}) [FAILED]')

0 commit comments

Comments
 (0)