diff --git a/airflow/template/templater.py b/airflow/template/templater.py index 2d2033696b6d2..19eb3f59965f8 100644 --- a/airflow/template/templater.py +++ b/airflow/template/templater.py @@ -70,7 +70,7 @@ def resolve_template_files(self) -> None: content = getattr(self, field, None) if content is None: continue - elif isinstance(content, str) and any(content.endswith(ext) for ext in self.template_ext): + elif isinstance(content, str) and content.endswith(tuple(self.template_ext)): env = self.get_template_env() try: setattr(self, field, env.loader.get_source(env, content)[0]) # type: ignore @@ -79,7 +79,7 @@ def resolve_template_files(self) -> None: elif isinstance(content, list): env = self.get_template_env() for i, item in enumerate(content): - if isinstance(item, str) and any(item.endswith(ext) for ext in self.template_ext): + if isinstance(item, str) and item.endswith(tuple(self.template_ext)): try: content[i] = env.loader.get_source(env, item)[0] # type: ignore except Exception: @@ -150,7 +150,7 @@ def render_template( jinja_env = self.get_template_env() if isinstance(value, str): - if any(value.endswith(ext) for ext in self.template_ext): # A filepath. + if value.endswith(tuple(self.template_ext)): # A filepath. template = jinja_env.get_template(value) else: template = jinja_env.from_string(value) diff --git a/dev/chart/build_changelog_annotations.py b/dev/chart/build_changelog_annotations.py index 259bd7dac4060..fc38a47dcbf73 100755 --- a/dev/chart/build_changelog_annotations.py +++ b/dev/chart/build_changelog_annotations.py @@ -96,7 +96,7 @@ def print_entry(section: str, description: str, pr_number: int | None): break in_first_release = True continue - if line.startswith('"""') or line.startswith("----") or line.startswith("^^^^"): + if line.startswith(('"""', "----", "^^^^")): continue # Make sure we get past "significant features" before we actually start keeping track diff --git a/scripts/ci/pre_commit/pre_commit_update_providers_dependencies.py b/scripts/ci/pre_commit/pre_commit_update_providers_dependencies.py index 0c489bad63e35..508ca72abee50 100755 --- a/scripts/ci/pre_commit/pre_commit_update_providers_dependencies.py +++ b/scripts/ci/pre_commit/pre_commit_update_providers_dependencies.py @@ -126,7 +126,7 @@ def get_provider_id_from_import(import_name: str, file_path: Path) -> str | None provider_id = get_provider_id_from_relative_import_or_file(relative_provider_import) if provider_id is None: relative_path_from_import = relative_provider_import.replace(".", os.sep) - if any(relative_path_from_import.startswith(suspended_path) for suspended_path in suspended_paths): + if relative_path_from_import.startswith(tuple(suspended_paths)): return None warnings.append(f"We could not determine provider id from import {import_name} in {file_path}") return provider_id @@ -154,7 +154,7 @@ def get_provider_id_from_file_name(file_path: Path) -> str | None: return None provider_id = get_provider_id_from_relative_import_or_file(str(relative_path)) if provider_id is None and file_path.name not in ["__init__.py", "get_provider_info.py"]: - if any(relative_path.as_posix().startswith(suspended_path) for suspended_path in suspended_paths): + if relative_path.as_posix().startswith(tuple(suspended_paths)): return None else: warnings.append(f"We had a problem to classify the file {file_path} to a provider") diff --git a/scripts/in_container/run_provider_yaml_files_check.py b/scripts/in_container/run_provider_yaml_files_check.py index e2caeea93b33d..ae523eb4babca 100755 --- a/scripts/in_container/run_provider_yaml_files_check.py +++ b/scripts/in_container/run_provider_yaml_files_check.py @@ -419,19 +419,18 @@ def check_doc_files(yaml_files: dict[str, dict]): for f in expected_doc_files if f.name != "index.rst" and "_partials" not in f.parts - and not any(f.relative_to(DOCS_DIR).as_posix().startswith(s) for s in suspended_providers) + and not f.relative_to(DOCS_DIR).as_posix().startswith(tuple(suspended_providers)) } | { f"/docs/{f.relative_to(DOCS_DIR).as_posix()}" for f in DOCS_DIR.glob("apache-airflow-providers-*/operators.rst") - if not any(f.relative_to(DOCS_DIR).as_posix().startswith(s) for s in suspended_providers) + if not f.relative_to(DOCS_DIR).as_posix().startswith(tuple(suspended_providers)) } console.print("[yellow]Suspended logos:[/]") console.print(suspended_logos) expected_logo_urls = { f"/{f.relative_to(DOCS_DIR).as_posix()}" for f in DOCS_DIR.glob("integration-logos/**/*") - if f.is_file() - and not any(f"/{f.relative_to(DOCS_DIR).as_posix()}".startswith(s) for s in suspended_logos) + if f.is_file() and not f"/{f.relative_to(DOCS_DIR).as_posix()}".startswith(tuple(suspended_logos)) } try: diff --git a/scripts/in_container/verify_providers.py b/scripts/in_container/verify_providers.py index 6df9f9900fb21..e6f6fa140a26d 100755 --- a/scripts/in_container/verify_providers.py +++ b/scripts/in_container/verify_providers.py @@ -170,9 +170,9 @@ def mk_prefix(provider_id): return f"{prefix}{provider_id}" if provider_ids: - provider_prefixes = [mk_prefix(provider_id) for provider_id in provider_ids] + provider_prefixes = tuple(mk_prefix(provider_id) for provider_id in provider_ids) else: - provider_prefixes = [prefix] + provider_prefixes = (prefix,) def onerror(_): nonlocal tracebacks @@ -187,7 +187,7 @@ def onerror(_): for path, prefix in walkable_paths_and_prefixes.items(): for modinfo in pkgutil.walk_packages(path=[path], prefix=prefix, onerror=onerror): - if not modinfo.name.startswith(tuple(provider_prefixes)): + if not modinfo.name.startswith(provider_prefixes): if print_skips: console.print(f"Skipping module: {modinfo.name}") continue diff --git a/setup.py b/setup.py index 7dc2e9f6eb58a..9dd5ecbf8fcc3 100644 --- a/setup.py +++ b/setup.py @@ -710,7 +710,7 @@ def is_package_excluded(package: str, exclusion_list: list[str]) -> bool: :param exclusion_list: list of excluded packages :return: true if package should be excluded """ - return any(package.startswith(excluded_package) for excluded_package in exclusion_list) + return package.startswith(tuple(exclusion_list)) def remove_provider_limits(package: str) -> str: