You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/07/14 08:05:10 UTC

[airflow] branch master updated: Remove unnecessary comprehension (#9805)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 0eb5020  Remove unnecessary comprehension (#9805)
0eb5020 is described below

commit 0eb5020fda46a6eceaa3652846598cb4ba34493b
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Tue Jul 14 09:04:14 2020 +0100

    Remove unnecessary comprehension (#9805)
---
 airflow/executors/celery_executor.py             | 2 +-
 airflow/models/baseoperator.py                   | 4 ++--
 airflow/operators/sql.py                         | 2 +-
 airflow/utils/file.py                            | 2 +-
 airflow/www/security.py                          | 2 +-
 backport_packages/import_all_provider_classes.py | 4 ++--
 tests/jobs/test_backfill_job.py                  | 4 ++--
 tests/models/test_taskinstance.py                | 2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/airflow/executors/celery_executor.py b/airflow/executors/celery_executor.py
index ab4701b..96771ae 100644
--- a/airflow/executors/celery_executor.py
+++ b/airflow/executors/celery_executor.py
@@ -260,7 +260,7 @@ class CeleryExecutor(BaseExecutor):
 
     def end(self, synchronous: bool = False) -> None:
         if synchronous:
-            while any([task.state not in celery_states.READY_STATES for task in self.tasks.values()]):
+            while any(task.state not in celery_states.READY_STATES for task in self.tasks.values()):
                 time.sleep(5)
         self.sync()
 
diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py
index 3b4c488..226994e 100644
--- a/airflow/models/baseoperator.py
+++ b/airflow/models/baseoperator.py
@@ -961,7 +961,7 @@ class BaseOperator(Operator, LoggingMixin, metaclass=BaseOperatorMeta):
                 if content is None:  # pylint: disable=no-else-continue
                     continue
                 elif isinstance(content, str) and \
-                        any([content.endswith(ext) for ext in self.template_ext]):
+                        any(content.endswith(ext) for ext in self.template_ext):
                     env = self.get_template_env()
                     try:
                         setattr(self, field, env.loader.get_source(env, content)[0])
@@ -971,7 +971,7 @@ class BaseOperator(Operator, LoggingMixin, metaclass=BaseOperatorMeta):
                     env = self.dag.get_template_env()
                     for i in range(len(content)):  # pylint: disable=consider-using-enumerate
                         if isinstance(content[i], str) and \
-                                any([content[i].endswith(ext) for ext in self.template_ext]):
+                                any(content[i].endswith(ext) for ext in self.template_ext):
                             try:
                                 content[i] = env.loader.get_source(env, content[i])[0]
                             except Exception as e:  # pylint: disable=broad-except
diff --git a/airflow/operators/sql.py b/airflow/operators/sql.py
index a5efbd5..a0427f3 100644
--- a/airflow/operators/sql.py
+++ b/airflow/operators/sql.py
@@ -95,7 +95,7 @@ class SQLCheckOperator(BaseOperator):
         self.log.info("Record: %s", records)
         if not records:
             raise AirflowException("The query returned None")
-        elif not all([bool(r) for r in records]):
+        elif not all(bool(r) for r in records):
             raise AirflowException(
                 "Test failed.\nQuery:\n{query}\nResults:\n{records!s}".format(
                     query=self.sql, records=records
diff --git a/airflow/utils/file.py b/airflow/utils/file.py
index 544daad..c3df1ca 100644
--- a/airflow/utils/file.py
+++ b/airflow/utils/file.py
@@ -207,4 +207,4 @@ def might_contain_dag(file_path: str, safe_mode: bool, zip_file: Optional[zipfil
             return True
         with open(file_path, 'rb') as dag_file:
             content = dag_file.read()
-    return all([s in content for s in (b'DAG', b'airflow')])
+    return all(s in content for s in (b'DAG', b'airflow'))
diff --git a/airflow/www/security.py b/airflow/www/security.py
index 9359f71..276de0d 100644
--- a/airflow/www/security.py
+++ b/airflow/www/security.py
@@ -323,7 +323,7 @@ class AirflowSecurityManager(SecurityManager, LoggingMixin):
         if not isinstance(role_name_or_list, list):
             role_name_or_list = [role_name_or_list]
         return any(
-            [r.name in role_name_or_list for r in self.get_user_roles()])
+            r.name in role_name_or_list for r in self.get_user_roles())
 
     def _has_perm(self, permission_name, view_menu_name):
         """
diff --git a/backport_packages/import_all_provider_classes.py b/backport_packages/import_all_provider_classes.py
index 2a3beac..38720a6 100755
--- a/backport_packages/import_all_provider_classes.py
+++ b/backport_packages/import_all_provider_classes.py
@@ -46,8 +46,8 @@ def import_all_provider_classes(source_path: str,
     imported_classes = []
     tracebacks = []
     for root, _, files in os.walk(source_path):
-        if all([not root.startswith(prefix_provider_path)
-                for prefix_provider_path in prefixed_provider_paths]) or root.endswith("__pycache__"):
+        if all(not root.startswith(prefix_provider_path)
+                for prefix_provider_path in prefixed_provider_paths) or root.endswith("__pycache__"):
             # Skip loading module if it is not in the list of providers that we are looking for
             continue
         package_name = root[len(source_path) + 1:].replace("/", ".")
diff --git a/tests/jobs/test_backfill_job.py b/tests/jobs/test_backfill_job.py
index d9a7dcf..7962172 100644
--- a/tests/jobs/test_backfill_job.py
+++ b/tests/jobs/test_backfill_job.py
@@ -910,7 +910,7 @@ class TestBackfillJob(unittest.TestCase):
 
         dagruns = DagRun.find(dag_id=dag.dag_id)
         self.assertEqual(2, len(dagruns))
-        self.assertTrue(all([run.state == State.SUCCESS for run in dagruns]))
+        self.assertTrue(all(run.state == State.SUCCESS for run in dagruns))
 
     def test_backfill_max_limit_check(self):
         dag_id = 'test_backfill_max_limit_check'
@@ -1437,7 +1437,7 @@ class TestBackfillJob(unittest.TestCase):
 
         queued_times = [ti.queued_dttm for ti in tis]
         self.assertTrue(queued_times == sorted(queued_times, reverse=True))
-        self.assertTrue(all([ti.state == State.SUCCESS for ti in tis]))
+        self.assertTrue(all(ti.state == State.SUCCESS for ti in tis))
 
         dag.clear()
         session.close()
diff --git a/tests/models/test_taskinstance.py b/tests/models/test_taskinstance.py
index 6cd8330..4b30e09 100644
--- a/tests/models/test_taskinstance.py
+++ b/tests/models/test_taskinstance.py
@@ -862,7 +862,7 @@ class TestTaskInstance(unittest.TestCase):
             done=done,
             flag_upstream_failed=flag_upstream_failed,
         )
-        completed = all([dep.passed for dep in dep_results])
+        completed = all(dep.passed for dep in dep_results)
 
         self.assertEqual(completed, expect_completed)
         self.assertEqual(ti.state, expect_state)