Skip to content

Commit

Permalink
Refactor unneeded continue jumps in dev (#33832)
Browse files Browse the repository at this point in the history
  • Loading branch information
eumiro authored Sep 1, 2023
1 parent 875387a commit 8a9988a
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ def status(kubernetes_version: str, python: str, wait_time_in_seconds: int, all:
found_python, found_kubernetes_version = _get_python_kubernetes_version_from_name(name)
if not found_python or not found_kubernetes_version:
get_console().print(f"[warning]\nCould not get cluster from {name}. Skipping.\n")
continue
if not _status(
elif not _status(
python=found_python,
kubernetes_version=found_kubernetes_version,
wait_time_in_seconds=wait_time_in_seconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,10 @@ def get_prs_for_package(package_id: str) -> list[int]:
if skip_line:
# Skip first "....." header
skip_line = False
continue
if line.strip() == current_release_version:
elif line.strip() == current_release_version:
extract_prs = True
skip_line = True
continue
if extract_prs:
elif extract_prs:
if len(line) > 1 and all(c == "." for c in line.strip()):
# Header for next version reached
break
Expand Down
36 changes: 13 additions & 23 deletions dev/breeze/src/airflow_breeze/commands/setup_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,9 @@ def remove_autogenerated_code(script_path: str):
for line in lines:
if line == START_LINE:
pass_through = False
continue
if line.startswith(END_LINE):
elif line.startswith(END_LINE):
pass_through = True
continue
if pass_through:
elif pass_through:
new_lines.append(line)
Path(script_path).write_text("".join(new_lines))

Expand All @@ -392,9 +390,8 @@ def get_commands() -> list[str]:
content = COMMAND_HASH_FILE_PATH.read_text()
for line in content.splitlines():
strip_line = line.strip()
if strip_line == "" or strip_line.startswith("#"):
continue
results.append(":".join(strip_line.split(":")[:-1]))
if strip_line and not strip_line.startswith("#"):
results.append(":".join(strip_line.split(":")[:-1]))
return results


Expand All @@ -410,11 +407,9 @@ def get_command_hash_dict(hash_file_content: str) -> dict[str, str]:
results = {}
for line in hash_file_content.splitlines():
strip_line = line.strip()
if not strip_line or strip_line.startswith("#"):
continue
command = ":".join(strip_line.split(":")[:-1])
the_hash = strip_line.split(":")[-1]
results[command] = the_hash
if strip_line and not strip_line.startswith("#"):
command, the_hash = strip_line.rsplit(":", 1)
results[command] = the_hash
return results


Expand Down Expand Up @@ -484,17 +479,12 @@ def regenerate_help_images_for_all_commands(commands: tuple[str, ...], check_onl
env=env,
)
for command in commands_list:
if command == "main":
continue

subcommands = command.split(":")
env["RECORD_BREEZE_TITLE"] = f"Command: {' '.join(subcommands)}"
env["RECORD_BREEZE_OUTPUT_FILE"] = str(BREEZE_IMAGES_DIR / f"output_{'_'.join(subcommands)}.svg")
env["RECORD_BREEZE_UNIQUE_ID"] = f"breeze-{'-'.join(subcommands)}"
run_command(
["breeze", *subcommands, "--help"],
env=env,
)
if command != "main":
subcommands = command.split(":")
env["RECORD_BREEZE_TITLE"] = f"Command: {' '.join(subcommands)}"
env["RECORD_BREEZE_OUTPUT_FILE"] = str(BREEZE_IMAGES_DIR / f"output_{'_'.join(subcommands)}.svg")
env["RECORD_BREEZE_UNIQUE_ID"] = f"breeze-{'-'.join(subcommands)}"
run_command(["breeze", *subcommands, "--help"], env=env)
if regenerate_all_commands:
COMMAND_HASH_FILE_PATH.write_text(new_hash_text_dump)
get_console().print(f"\n[info]New hash of breeze commands written in {COMMAND_HASH_FILE_PATH}\n")
Expand Down
1 change: 0 additions & 1 deletion dev/breeze/src/airflow_breeze/utils/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def user_confirm(
if default_answer:
return default_answer
# timeout should only occur when default_answer is set so this should never happened
continue
except KeyboardInterrupt:
if quit_allowed:
return Answer.QUIT
Expand Down
1 change: 0 additions & 1 deletion dev/breeze/src/airflow_breeze/utils/kubernetes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def _download_with_retries(num_tries, path, tool, url):
f"[warning]Retrying: {num_tries} retries left on error "
f"while downloading {tool} tool: {e}"
)
continue


def _download_tool_if_needed(
Expand Down
11 changes: 5 additions & 6 deletions dev/breeze/src/airflow_breeze/utils/provider_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ def generate_providers_metadata_for_package(
date_released = get_tag_date(
tag="providers-" + provider_id.replace(".", "-") + "/" + provider_version
)
if date_released is None:
continue
provider_metadata[provider_version] = {
"associated_airflow_version": last_airflow_version,
"date_released": date_released,
}
if date_released:
provider_metadata[provider_version] = {
"associated_airflow_version": last_airflow_version,
"date_released": date_released,
}
return provider_metadata
3 changes: 1 addition & 2 deletions dev/breeze/src/airflow_breeze/utils/run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ def get_filesystem_type(filepath: str):
for part in psutil.disk_partitions(all=True):
if part.mountpoint == "/":
root_type = part.fstype
continue
if filepath.startswith(part.mountpoint):
elif filepath.startswith(part.mountpoint):
return part.fstype

return root_type
Expand Down
25 changes: 9 additions & 16 deletions dev/chart/build_changelog_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,21 @@ def print_entry(section: str, description: str, pr_number: int | None):
with open("chart/RELEASE_NOTES.rst") as f:
for line in f:
line = line.strip()
if not line:
continue
if line.startswith("Airflow Helm Chart"):
if not line or line.startswith(('"""', "----", "^^^^")):
pass
elif line.startswith("Airflow Helm Chart"):
# We only want to get annotations for the "latest" release
if in_first_release:
break
in_first_release = True
continue
if line.startswith(('"""', "----", "^^^^")):
continue

# Make sure we get past "significant features" before we actually start keeping track
if not past_significant_changes:
elif not past_significant_changes:
if line == "New Features":
section = line
past_significant_changes = True
continue

if not line.startswith("- "):
elif not line.startswith("- "):
section = line
continue

description, pr = parse_line(line)
if description:
print_entry(section, description, pr)
else:
description, pr = parse_line(line)
if description:
print_entry(section, description, pr)
7 changes: 3 additions & 4 deletions dev/check_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ def get_packages() -> list[tuple[str, str]]:

packages = []
for line in content.splitlines():
if not line:
continue
name, version = line.rstrip("/").split("/")[-2:]
packages.append((name, version))
if line:
_, name, version = line.rstrip("/").rsplit("/", 2)
packages.append((name, version))

return packages

Expand Down
15 changes: 7 additions & 8 deletions dev/perf/sql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,15 @@ def main() -> None:
rows = []
times = []

for i in range(4):
for test_no in range(4):
sleep(5)
queries, exec_time = run_test()
if i == 0:
continue
times.append(exec_time)
for qry in queries:
info = qry.to_dict()
info["test_no"] = i
rows.append(info)
if test_no:
times.append(exec_time)
for qry in queries:
info = qry.to_dict()
info["test_no"] = test_no
rows.append(info)

rows_to_csv(rows, name="/files/sql_after_remote.csv")
print(times)
Expand Down
5 changes: 2 additions & 3 deletions dev/prepare_bulk_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ def prepare_bulk_issues(
with open(csv_file) as f:
read_issues = csv.reader(f)
for index, row in enumerate(read_issues):
if index == 0:
continue
issues[row[0]].append(row)
if index:
issues[row[0]].append(row)
names = sorted(issues.keys())[start_from:]
total_issues = len(names)
processed_issues = 0
Expand Down
8 changes: 3 additions & 5 deletions dev/provider_packages/prepare_provider_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,7 @@ def get_additional_package_info(provider_package_path: str) -> str:
for line in additional_info_lines:
if line.startswith(" -->"):
skip_comment = False
continue
if not skip_comment:
elif not skip_comment:
result += line
return result
return ""
Expand Down Expand Up @@ -1679,9 +1678,8 @@ def list_providers_packages():
# this is useful for cases where provider is WIP for a long period thus we don't want to release it yet.
providers_to_remove_from_release = []
for provider in providers:
if provider in providers_to_remove_from_release:
continue
console.print(provider)
if provider not in providers_to_remove_from_release:
console.print(provider)


@cli.command()
Expand Down

0 comments on commit 8a9988a

Please sign in to comment.