This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v1-10-stable
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-stable by this push:
new d3b0669 Fix false positive when inheriting class that inherits
``DbApiHook`` (#16543)
d3b0669 is described below
commit d3b066931191b82880d216af103517ea941c74ba
Author: Kaxil Naik <[email protected]>
AuthorDate: Sat Jun 19 21:00:53 2021 +0100
Fix false positive when inheriting class that inherits ``DbApiHook``
(#16543)
closes https://github.com/apache/airflow/issues/14541
---
airflow/upgrade/rules/db_api_functions.py | 5 +++--
tests/upgrade/rules/test_db_api_functions.py | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/airflow/upgrade/rules/db_api_functions.py
b/airflow/upgrade/rules/db_api_functions.py
index 0ca730f..dbf72d6 100644
--- a/airflow/upgrade/rules/db_api_functions.py
+++ b/airflow/upgrade/rules/db_api_functions.py
@@ -63,8 +63,9 @@ def get_all_non_dbapi_children():
next_generation = []
for child in basehook_children:
subclasses = child.__subclasses__()
- if subclasses:
- next_generation.extend(subclasses)
+ for subclass in subclasses:
+ if all(base_class.__name__ != 'DbApiHook' for base_class in
subclass.__bases__):
+ next_generation.append(subclass)
res.extend(next_generation)
basehook_children = next_generation
return res
diff --git a/tests/upgrade/rules/test_db_api_functions.py
b/tests/upgrade/rules/test_db_api_functions.py
index d73a041..156e7d5 100644
--- a/tests/upgrade/rules/test_db_api_functions.py
+++ b/tests/upgrade/rules/test_db_api_functions.py
@@ -18,6 +18,7 @@ from unittest import TestCase
from airflow.hooks.base_hook import BaseHook
from airflow.hooks.dbapi_hook import DbApiHook
+from airflow.contrib.hooks.bigquery_hook import BigQueryHook
from airflow.upgrade.rules.db_api_functions import DbApiRule
@@ -41,7 +42,7 @@ class GrandChildHook(MyHook):
pass
-class ProperDbApiHook(DbApiHook):
+class ProperDbApiHook(DbApiHook, BigQueryHook):
def bulk_dump(self, table, tmp_file):
pass