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 918bd33993 Protect against using try_number from context in provider
(#23069)
918bd33993 is described below
commit 918bd3399328de45999f684eb552c8a65de11e53
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Apr 19 18:47:00 2022 +0200
Protect against using try_number from context in provider (#23069)
This is a (temporary and not perfect - until we figure out a better way)
protection against using constructs and interfaces which are not
present in Airflow 2.1 in providers.
Follow-up after #23059
---
scripts/ci/pre_commit/pre_commit_check_2_1_compatibility.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/ci/pre_commit/pre_commit_check_2_1_compatibility.py
b/scripts/ci/pre_commit/pre_commit_check_2_1_compatibility.py
index 1267585d79..0d43959ba5 100755
--- a/scripts/ci/pre_commit/pre_commit_check_2_1_compatibility.py
+++ b/scripts/ci/pre_commit/pre_commit_check_2_1_compatibility.py
@@ -35,6 +35,7 @@ errors: List[str] = []
GET_ATTR_MATCHER = re.compile(r".*getattr\((ti|TI), ['\"]run_id['\"]\).*")
TI_RUN_ID_MATCHER = re.compile(r".*(ti|TI)\.run_id.*")
+TRY_NUM_MATCHER = re.compile(r".*context.*\[[\"']try_number[\"']].*")
def _check_file(_file: Path):
@@ -81,6 +82,15 @@ def _check_file(_file: Path):
f"as it is not available in Airflow 2.2[/]"
)
+ if TRY_NUM_MATCHER.match(line):
+ errors.append(
+ f"[red]In {_file}:{index} there is a forbidden construct "
+ f"(Airflow 2.3+ only):[/]\n\n"
+ f"{lines[index]}\n\n"
+ f"[yellow]You should not expect try_number field for context
in providers "
+ f"as it is not available in Airflow 2.2[/]"
+ )
+
if __name__ == '__main__':
for file in sys.argv[1:]: