This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ab091d1552 Refactor unneeded 'continue' jumps in docs (#33840)
ab091d1552 is described below
commit ab091d15521d14501f09aa1a786c6205ee928959
Author: Miroslav Šedivý <[email protected]>
AuthorDate: Fri Sep 1 18:12:16 2023 +0000
Refactor unneeded 'continue' jumps in docs (#33840)
---
docs/exts/extra_provider_files_with_substitutions.py | 12 +++++-------
docs/exts/operators_and_hooks_ref.py | 20 ++++++++------------
2 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/docs/exts/extra_provider_files_with_substitutions.py
b/docs/exts/extra_provider_files_with_substitutions.py
index 2ccd3cf935..065ba6a27b 100644
--- a/docs/exts/extra_provider_files_with_substitutions.py
+++ b/docs/exts/extra_provider_files_with_substitutions.py
@@ -28,13 +28,11 @@ def fix_provider_references(app, exception):
# Replace `|version|` in the files that require manual substitution
for path in Path(app.outdir).rglob("*.html"):
- if not path.exists():
- continue
- with open(path) as input_file:
- content = input_file.readlines()
- with open(path, "w") as output_file:
- for line in content:
- output_file.write(line.replace("|version|",
app.config.version))
+ if path.exists():
+ lines = path.read_text().splitlines(True)
+ with path.open("w") as output_file:
+ for line in lines:
+ output_file.write(line.replace("|version|",
app.config.version))
def setup(app):
diff --git a/docs/exts/operators_and_hooks_ref.py
b/docs/exts/operators_and_hooks_ref.py
index e5f61684e2..554043a2f7 100644
--- a/docs/exts/operators_and_hooks_ref.py
+++ b/docs/exts/operators_and_hooks_ref.py
@@ -165,9 +165,8 @@ def _prepare_transfer_data(tags: set[str] | None):
]
for transfer in to_display_transfers:
- if "how-to-guide" not in transfer:
- continue
- transfer["how-to-guide"] = _docs_path(transfer["how-to-guide"])
+ if "how-to-guide" in transfer:
+ transfer["how-to-guide"] = _docs_path(transfer["how-to-guide"])
return to_display_transfers
@@ -202,15 +201,12 @@ def _render_deferrable_operator_content(*,
header_separator: str):
provider_parent_path = Path(provider_yaml_path).parent
provider_info: dict[str, Any] = {"name": "", "operators": []}
for root, _, file_names in os.walk(provider_parent_path):
- if all([target not in root for target in ["operators",
"sensors"]]):
- continue
-
- for file_name in file_names:
- if not file_name.endswith(".py") or file_name == "__init__.py":
- continue
- provider_info["operators"].extend(
-
iter_deferrable_operators(f"{os.path.relpath(root)}/{file_name}")
- )
+ if "operators" in root or "sensors" in root:
+ for file_name in file_names:
+ if file_name.endswith(".py") and file_name !=
"__init__.py":
+ provider_info["operators"].extend(
+
iter_deferrable_operators(f"{os.path.relpath(root)}/{file_name}")
+ )
if provider_info["operators"]:
provider_yaml_content =
yaml.safe_load(Path(provider_yaml_path).read_text())