Repository: kedro-org/kedro

Issue:
Remove deprecated `project_version`
`project_version` was deprecated in favour of `kedro_init_version` in https://github.com/kedro-org/kedro/issues/2118 and https://github.com/kedro-org/kedro/pull/2219, but hasn't been removed yet. 


Discussion:
I intend to do this first because I find that I need to update ProjectMetadata for https://github.com/kedro-org/kedro/pull/3188. It would be cleaner to update ProjectMetadata in 1 complete PR

Resolving patch:
diff --git a/kedro/framework/startup.py b/kedro/framework/startup.py
--- a/kedro/framework/startup.py
+++ b/kedro/framework/startup.py
@@ -1,13 +1,11 @@
 """This module provides metadata for a Kedro project."""
 import os
 import sys
-import warnings
 from pathlib import Path
 from typing import NamedTuple, Union
 
 import anyconfig
 
-from kedro import KedroDeprecationWarning
 from kedro import __version__ as kedro_version
 from kedro.framework.project import configure_project
 
@@ -21,9 +19,9 @@ class ProjectMetadata(NamedTuple):
     package_name: str
     project_name: str
     project_path: Path
-    project_version: str
     source_dir: Path
     kedro_init_version: str
+    add_ons: list
 
 
 def _version_mismatch_error(kedro_init_version) -> str:
@@ -89,26 +87,11 @@ def _get_project_metadata(project_path: Union[str, Path]) -> ProjectMetadata:
             f"configuration parameters."
         ) from exc
 
-    mandatory_keys = ["package_name", "project_name"]
+    mandatory_keys = ["package_name", "project_name", "kedro_init_version"]
     missing_keys = [key for key in mandatory_keys if key not in metadata_dict]
     if missing_keys:
         raise RuntimeError(f"Missing required keys {missing_keys} from '{_PYPROJECT}'.")
 
-    # Temporary solution to keep project_version backwards compatible to be removed in 0.19.0
-    if "project_version" in metadata_dict:
-        warnings.warn(
-            "project_version in pyproject.toml is deprecated, use kedro_init_version instead",
-            KedroDeprecationWarning,
-        )
-        metadata_dict["kedro_init_version"] = metadata_dict["project_version"]
-    elif "kedro_init_version" in metadata_dict:
-        metadata_dict["project_version"] = metadata_dict["kedro_init_version"]
-    else:
-        raise RuntimeError(
-            f"Missing required key kedro_init_version from '{_PYPROJECT}'."
-        )
-
-    mandatory_keys.append("kedro_init_version")
     # check the match for major and minor version (skip patch version)
     if (
         metadata_dict["kedro_init_version"].split(".")[:2]
@@ -116,8 +99,11 @@ def _get_project_metadata(project_path: Union[str, Path]) -> ProjectMetadata:
     ):
         raise ValueError(_version_mismatch_error(metadata_dict["kedro_init_version"]))
 
+    # Default settings
     source_dir = Path(metadata_dict.get("source_dir", "src")).expanduser()
     source_dir = (project_path / source_dir).resolve()
+    metadata_dict["add_ons"] = metadata_dict.get("add_ons")
+
     metadata_dict["source_dir"] = source_dir
     metadata_dict["config_file"] = pyproject_toml
     metadata_dict["project_path"] = project_path


Test patch:
diff --git a/tests/framework/cli/conftest.py b/tests/framework/cli/conftest.py
--- a/tests/framework/cli/conftest.py
+++ b/tests/framework/cli/conftest.py
@@ -82,13 +82,13 @@ def dummy_config(fake_root_dir, fake_metadata):
 @fixture(scope="module")
 def fake_metadata(fake_root_dir):
     metadata = ProjectMetadata(
-        fake_root_dir / REPO_NAME / "pyproject.toml",
-        PACKAGE_NAME,
-        "CLI Testing Project",
-        fake_root_dir / REPO_NAME,
-        kedro_version,
-        fake_root_dir / REPO_NAME / "src",
-        kedro_version,
+        config_file=fake_root_dir / REPO_NAME / "pyproject.toml",
+        package_name=PACKAGE_NAME,
+        project_name="CLI Testing Project",
+        project_path=fake_root_dir / REPO_NAME,
+        kedro_init_version=kedro_version,
+        source_dir=fake_root_dir / REPO_NAME / "src",
+        add_ons=None,
     )
     return metadata
 
diff --git a/tests/framework/test_startup.py b/tests/framework/test_startup.py
--- a/tests/framework/test_startup.py
+++ b/tests/framework/test_startup.py
@@ -92,9 +92,9 @@ def test_valid_toml_file(self, mocker):
             config_file=self.project_path / "pyproject.toml",
             package_name="fake_package_name",
             project_name="fake_project_name",
-            project_version=kedro_version,
             kedro_init_version=kedro_version,
             project_path=self.project_path,
+            add_ons=None,
         )
         assert actual == expected
 
@@ -106,7 +106,7 @@ def test_valid_toml_file_with_project_version(self, mocker):
                 "kedro": {
                     "package_name": "fake_package_name",
                     "project_name": "fake_project_name",
-                    "project_version": kedro_version,
+                    "kedro_init_version": kedro_version,
                 }
             }
         }
@@ -119,9 +119,9 @@ def test_valid_toml_file_with_project_version(self, mocker):
             config_file=self.project_path / "pyproject.toml",
             package_name="fake_package_name",
             project_name="fake_project_name",
-            project_version=kedro_version,
             kedro_init_version=kedro_version,
             project_path=self.project_path,
+            add_ons=None,
         )
         assert actual == expected
 
@@ -230,7 +230,7 @@ def test_invalid_version_for_kedro_version(self, invalid_version, mocker):
                     "source_dir": "source_dir",
                     "package_name": "fake_package_name",
                     "project_name": "fake_project_name",
-                    "project_version": invalid_version,
+                    "kedro_init_version": invalid_version,
                 }
             }
         }
@@ -243,23 +243,6 @@ def test_invalid_version_for_kedro_version(self, invalid_version, mocker):
         with pytest.raises(ValueError, match=re.escape(pattern)):
             _get_project_metadata(self.project_path)
 
-    def test_toml_file_has_missing_version(self, mocker):
-        mocker.patch.object(Path, "is_file", return_value=True)
-        pyproject_toml_payload = {
-            "tool": {
-                "kedro": {
-                    "source_dir": "source_dir",
-                    "package_name": "fake_package_name",
-                    "project_name": "fake_project_name",
-                }
-            }
-        }
-        mocker.patch("anyconfig.load", return_value=pyproject_toml_payload)
-        pattern = "Missing required key kedro_init_version from 'pyproject.toml'."
-
-        with pytest.raises(RuntimeError, match=re.escape(pattern)):
-            _get_project_metadata(self.project_path)
-
 
 class TestValidateSourcePath:
     @pytest.mark.parametrize(
@@ -315,9 +298,9 @@ def test_bootstrap_project(self, monkeypatch, tmp_path):
             "package_name": "fake_package_name",
             "project_name": "fake_project_name",
             "project_path": tmp_path,
-            "project_version": kedro_version,
             "kedro_init_version": kedro_version,
             "source_dir": src_dir,
+            "add_ons": None,
         }
         assert result == ProjectMetadata(**expected_metadata)
         assert str(src_dir) in sys.path[0]
diff --git a/tests/ipython/test_ipython.py b/tests/ipython/test_ipython.py
--- a/tests/ipython/test_ipython.py
+++ b/tests/ipython/test_ipython.py
@@ -11,7 +11,7 @@
 
 PACKAGE_NAME = "fake_package_name"
 PROJECT_NAME = "fake_project_name"
-PROJECT_VERSION = "0.1"
+PROJECT_INIT_VERSION = "0.1"
 
 
 @pytest.fixture(autouse=True)
@@ -36,9 +36,9 @@ def fake_metadata(tmp_path):
         config_file=tmp_path / "pyproject.toml",
         package_name=PACKAGE_NAME,
         project_name=PROJECT_NAME,
-        project_version=PROJECT_VERSION,
-        kedro_init_version=PROJECT_VERSION,
+        kedro_init_version=PROJECT_INIT_VERSION,
         project_path=tmp_path,
+        add_ons=None,
     )
     return metadata