bhirsz commented on code in PR #24666:
URL: https://github.com/apache/airflow/pull/24666#discussion_r907043729


##########
dev/breeze/src/airflow_breeze/utils/selective_checks.py:
##########
@@ -176,11 +185,64 @@ def __hash__(self):
         SelectiveUnitTestTypes.PROVIDERS: [
             "^airflow/providers/",
             "^tests/providers/",
+            "^tests/system/",
         ],
         SelectiveUnitTestTypes.WWW: ["^airflow/www", "^tests/www", 
"^airflow/ui"],
     }
 )
 
+TESTS_PROVIDERS_ROOT = AIRFLOW_SOURCES_ROOT / "tests" / "providers"
+SYSTEM_TESTS_PROVIDERS_ROOT = AIRFLOW_SOURCES_ROOT / "tests" / "system" / 
"providers"
+AIRFLOW_PROVIDERS_ROOT = AIRFLOW_SOURCES_ROOT / "airflow" / "providers"
+
+
+def find_provider_affected(changed_file: str) -> str | None:
+    file_path = AIRFLOW_SOURCES_ROOT / changed_file
+    # is_relative_to is only available in Python 3.9 - we should simplify this 
check when we are Python 3.9+
+    try:
+        file_path.relative_to(TESTS_PROVIDERS_ROOT)
+        relative_base_path = TESTS_PROVIDERS_ROOT
+    except ValueError:
+        try:
+            file_path.relative_to(SYSTEM_TESTS_PROVIDERS_ROOT)
+            relative_base_path = SYSTEM_TESTS_PROVIDERS_ROOT
+        except ValueError:
+            try:
+                file_path.relative_to(AIRFLOW_PROVIDERS_ROOT)
+                relative_base_path = AIRFLOW_PROVIDERS_ROOT
+            except ValueError:
+                return None

Review Comment:
   Other way of writing this
   ```suggestion
       for provider_root in (TESTS_PROVIDERS_ROOT, SYSTEM_TESTS_PROVIDERS_ROOT, 
AIRFLOW_PROVIDERS_ROOT):
           try:
               file_path.relative_to(provider_root )
               relative_base_path = provider_root
               break
           except ValueError:
               pass
       else:
           return None
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to