Skip to content

Commit

Permalink
Fix style (#13518)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret authored Dec 19, 2022
1 parent 7f027f2 commit 7489d48
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def config(ctx, check, sync, verbose):
spec_file_path = manifest.get_config_spec()
if not file_exists(spec_file_path):
check_display_queue.append(
lambda: echo_warning(f"Did not find spec file {spec_file_path} for check {check}")
lambda spec_file_path=spec_file_path, check=check: echo_warning(
f"Did not find spec file {spec_file_path} for check {check}"
)
)

validate_config_legacy(check, check_display_queue, files_failed, files_warned, file_counter)
Expand Down Expand Up @@ -98,7 +100,7 @@ def config(ctx, check, sync, verbose):

if not default_temp:
message = "Missing default template in init_config or instances section"
check_display_queue.append(lambda **kwargs: echo_failure(message))
check_display_queue.append(lambda message=message: echo_failure(message))
annotate_error(spec_file_path, message)

if spec.errors:
Expand All @@ -109,7 +111,7 @@ def config(ctx, check, sync, verbose):
if spec.data['name'] != display_name:
files_failed[spec_file_path] = True
message = f"Spec name `{spec.data['name']}` should be `{display_name}`"
check_display_queue.append(lambda **kwargs: echo_failure(message, **kwargs))
check_display_queue.append(lambda message=message, **kwargs: echo_failure(message, **kwargs))
annotate_error(spec_file_path, message)

example_location = get_data_directory(check)
Expand All @@ -136,7 +138,7 @@ def config(ctx, check, sync, verbose):
):
message += f'\n{diff_line}'
check_display_queue.append(
lambda example_file=example_file, **kwargs: echo_failure(message, **kwargs)
lambda message=message, **kwargs: echo_failure(message, **kwargs)
)
annotate_error(example_file_path, message)

Expand Down Expand Up @@ -203,9 +205,9 @@ def validate_config_legacy(check, check_display_queue, files_failed, files_warne
# We must convert to text here to free Exception object before it goes out of scope
error = str(e)

check_display_queue.append(lambda: echo_info(f'{file_name}:', indent=True))
check_display_queue.append(lambda file_name=file_name: echo_info(f'{file_name}:', indent=True))
check_display_queue.append(lambda: echo_failure('Invalid YAML -', indent=FILE_INDENT))
check_display_queue.append(lambda: echo_info(error, indent=FILE_INDENT * 2))
check_display_queue.append(lambda error=error: echo_info(error, indent=FILE_INDENT * 2))
continue

file_display_queue = []
Expand All @@ -225,15 +227,15 @@ def validate_config_legacy(check, check_display_queue, files_failed, files_warne
if 'instances' not in config_data:
files_failed[config_file] = True
message = 'Missing `instances` section'
file_display_queue.append(lambda: echo_failure(message, indent=FILE_INDENT))
file_display_queue.append(lambda message=message: echo_failure(message, indent=FILE_INDENT))
annotate_error(file_name, message)
# Verify there is a default instance
else:
instances = config_data['instances']
if check not in IGNORE_DEFAULT_INSTANCE and not isinstance(instances, list):
files_failed[config_file] = True
message = 'No default instance'
file_display_queue.append(lambda: echo_failure(message, indent=FILE_INDENT))
file_display_queue.append(lambda message=message: echo_failure(message, indent=FILE_INDENT))
annotate_error(file_name, message)

if file_display_queue:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def parse_from_strings(cls, start, config_lines, indent, errors):


def _get_end_of_param_declaration_block(start, end, config_lines, indent, errors, is_list=False):
"""Here we suppose the config block is correctly formatted (@param, description, empty comment then the actual content)
and try to return the line of any data coming after. In case of a object we point to its first member. In case
of a list or a simple variable we point to the next element.
"""Here we suppose the config block is correctly formatted (@param, description, empty comment then the
actual content) and try to return the line of any data coming after. In case of an object we point to its first
member. In case of a list or a simple variable we point to the next element.
"""

if not is_exactly_indented(config_lines[start], indent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def _parse_init_config(config_lines, init_config_start_line, errors):


def _parse_for_config_blocks(config_lines, start, end, errors):
"""The function basically do all the work. It reads the config from start, removes blank lines first then when it first
sees data, it sets the 'indent' variable once for all. All blocks read in a given function call must have the same
indentation. Sub-blocks are parsed recursively and thus the 'indent' variable is given a new value.
"""The function basically do all the work. It reads the config from start, removes blank lines first then when
it first sees data, it sets the 'indent' variable once for all. All blocks read in a given function call must
have the same indentation. Sub-blocks are parsed recursively and thus the 'indent' variable is given a new value.
Once a block is parsed the function will either recurse if the block requires it (see ConfigBlock), or it will go
to the next block and iterate.
"""
Expand Down

0 comments on commit 7489d48

Please sign in to comment.