From b4afa8f4e90dad6be3c8b87427fbbd2b5948f43b Mon Sep 17 00:00:00 2001 From: Hussein Awala Date: Fri, 1 Sep 2023 00:59:32 +0200 Subject: [PATCH] replace loop by any when looking for a positive value in core --- airflow/www/extensions/init_appbuilder.py | 5 +---- airflow/www/fab_security/sqla/manager.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/airflow/www/extensions/init_appbuilder.py b/airflow/www/extensions/init_appbuilder.py index 5ad9f0eabcf4d..37c86b5fb019b 100644 --- a/airflow/www/extensions/init_appbuilder.py +++ b/airflow/www/extensions/init_appbuilder.py @@ -645,10 +645,7 @@ def register_blueprint(self, baseview, endpoint=None, static_folder=None): ) def _view_exists(self, view): - for baseview in self.baseviews: - if baseview.__class__ == view.__class__: - return True - return False + return any(baseview.__class__ == view.__class__ for baseview in self.baseviews) def _process_inner_views(self): for view in self.baseviews: diff --git a/airflow/www/fab_security/sqla/manager.py b/airflow/www/fab_security/sqla/manager.py index 5084a24be87b2..4dabf9dcdd861 100644 --- a/airflow/www/fab_security/sqla/manager.py +++ b/airflow/www/fab_security/sqla/manager.py @@ -113,7 +113,4 @@ def filter_roles_by_perm_with_action(self, action_name: str, role_ids: list[int] ).all() def perms_include_action(self, perms, action_name): - for perm in perms: - if perm.action and perm.action.name == action_name: - return True - return False + return any(perm.action and perm.action.name == action_name for perm in perms)