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

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


The following commit(s) were added to refs/heads/main by this push:
     new 5bddd13ee67 Versionless bundles return None vs raising (#44574)
5bddd13ee67 is described below

commit 5bddd13ee67872c77c973d56a4876d4f5763c964
Author: Jed Cunningham <[email protected]>
AuthorDate: Mon Dec 2 12:34:17 2024 -0700

    Versionless bundles return None vs raising (#44574)
---
 airflow/dag_processing/bundles/base.py   | 2 +-
 airflow/dag_processing/bundles/local.py  | 5 ++---
 tests/dag_processing/test_dag_bundles.py | 5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/airflow/dag_processing/bundles/base.py 
b/airflow/dag_processing/bundles/base.py
index 34f3dd65c8b..05a9fd500ca 100644
--- a/airflow/dag_processing/bundles/base.py
+++ b/airflow/dag_processing/bundles/base.py
@@ -70,7 +70,7 @@ class BaseDagBundle(ABC):
         """
 
     @abstractmethod
-    def get_current_version(self) -> str:
+    def get_current_version(self) -> str | None:
         """
         Retrieve a string that represents the version of the DAG bundle.
 
diff --git a/airflow/dag_processing/bundles/local.py 
b/airflow/dag_processing/bundles/local.py
index dcbac969111..94369934184 100644
--- a/airflow/dag_processing/bundles/local.py
+++ b/airflow/dag_processing/bundles/local.py
@@ -20,7 +20,6 @@ from __future__ import annotations
 from pathlib import Path
 
 from airflow.dag_processing.bundles.base import BaseDagBundle
-from airflow.exceptions import AirflowException
 
 
 class LocalDagBundle(BaseDagBundle):
@@ -36,8 +35,8 @@ class LocalDagBundle(BaseDagBundle):
         super().__init__(**kwargs)
         self._path = Path(local_folder)
 
-    def get_current_version(self) -> str:
-        raise AirflowException("Not versioned!")
+    def get_current_version(self) -> None:
+        return None
 
     def refresh(self) -> None:
         """Nothing to refresh - it's just a local directory."""
diff --git a/tests/dag_processing/test_dag_bundles.py 
b/tests/dag_processing/test_dag_bundles.py
index 1a911a52eff..d3746c01a63 100644
--- a/tests/dag_processing/test_dag_bundles.py
+++ b/tests/dag_processing/test_dag_bundles.py
@@ -47,13 +47,12 @@ class TestLocalDagBundle:
         bundle = LocalDagBundle(name="test", local_folder="/hello")
         assert bundle.path == Path("/hello")
 
-    def test_does_not_support_versioning(self):
+    def test_none_for_version(self):
         assert LocalDagBundle.supports_versioning is False
 
         bundle = LocalDagBundle(name="test", local_folder="/hello")
 
-        with pytest.raises(AirflowException):
-            bundle.get_current_version()
+        assert bundle.get_current_version() is None
 
 
 @pytest.fixture

Reply via email to