From 063909af66017fb8f45d6c1fecacf66f46c039c3 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Mon, 13 Jan 2025 14:11:46 -0500 Subject: [PATCH] fix: more tests that rely on empty parts --- charmcraft/models/project.py | 6 ++++-- tests/unit/models/test_project.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/charmcraft/models/project.py b/charmcraft/models/project.py index 7ca986a21..2eb86be55 100644 --- a/charmcraft/models/project.py +++ b/charmcraft/models/project.py @@ -420,7 +420,6 @@ class CharmcraftProject(models.Project, metaclass=abc.ABCMeta): f"and ${const.STORE_REGISTRY_ENV_VAR} environment variables instead." ), ) - parts: dict[str, dict[str, Any]] = pydantic.Field(default_factory=dict) # Default project properties that Charmcraft currently does not use. Types are set # to be Optional[None], preventing them from being used, but allow them to be used @@ -1076,7 +1075,6 @@ class PlatformCharm(CharmProject): platforms: dict[str, models.Platform | None] # type: ignore[assignment] parts: dict[str, dict[str, Any]] = pydantic.Field( - default_factory=dict, description=textwrap.dedent( """\ Configures the various mechanisms to obtain, process and prepare data from @@ -1131,6 +1129,10 @@ class Bundle(CharmcraftProject): description: pydantic.StrictStr | None = None platforms: None = None # type: ignore[assignment] + parts: dict[str, dict[str, Any]] = pydantic.Field( + default_factory=lambda: {"bundle": {"plugin": "bundle", "source": "."}} + ) + @pydantic.model_validator(mode="before") @classmethod def preprocess_bundle(cls, values: dict[str, Any]) -> dict[str, Any]: diff --git a/tests/unit/models/test_project.py b/tests/unit/models/test_project.py index f23979396..7d64434e6 100644 --- a/tests/unit/models/test_project.py +++ b/tests/unit/models/test_project.py @@ -993,6 +993,7 @@ def test_from_yaml_file_exception( "description": "", "base": "ubuntu@24.04", "platforms": {"amd64": None}, + "parts": {"my-part": {"plugin": "nil"}}, "charmhub": {"api_url": "http://charmhub.io"}, }, ),