Remove unnecessary comprehension (#9805)

This commit is contained in:
Kaxil Naik 2020-07-14 09:04:14 +01:00 коммит произвёл GitHub
Родитель 468e9507ad
Коммит 0eb5020fda
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -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()

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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'))

Просмотреть файл

@ -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):
"""

Просмотреть файл

@ -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("/", ".")

Просмотреть файл

@ -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()

Просмотреть файл

@ -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)