Skip to content

Commit

Permalink
chore!: remove PluginModel class
Browse files Browse the repository at this point in the history
This class was vestigial, being a child of PluginPropertiesModel, while
all plugins' properties classes are children of PluginProperties,
which is itself a child of PluginPropertiesModel.

This is a breaking change because external plugins for applications
(e.g. snapcraft) inherit from both PluginProperties and PluginModel.
  • Loading branch information
lengau committed Jul 10, 2024
1 parent 6b15529 commit 257af9f
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 41 deletions.
3 changes: 1 addition & 2 deletions craft_parts/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"""Craft Parts plugins subsystem."""

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .plugins import (
PluginProperties,
extract_part_properties,
Expand All @@ -32,7 +32,6 @@
__all__ = [
"Plugin",
"PluginEnvironmentValidator",
"PluginModel",
"PluginProperties",
"extract_part_properties",
"extract_plugin_properties",
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/ant_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
from craft_parts import errors

from . import validator
from .base import JavaPlugin, PluginModel, extract_plugin_properties
from .base import JavaPlugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)


class AntPluginProperties(PluginProperties, PluginModel):
class AntPluginProperties(PluginProperties):
"""The part properties used by the Ant plugin."""

ant_build_targets: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/autotools_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

from overrides import override

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class AutotoolsPluginProperties(PluginProperties, PluginModel):
class AutotoolsPluginProperties(PluginProperties):
"""The part properties used by the autotools plugin."""

autotools_configure_parameters: list[str] = []
Expand Down
11 changes: 1 addition & 10 deletions craft_parts/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from craft_parts.actions import ActionProperties

from .properties import PluginProperties, PluginPropertiesModel
from .properties import PluginProperties
from .validator import PluginEnvironmentValidator

if TYPE_CHECKING:
Expand Down Expand Up @@ -122,15 +122,6 @@ def _get_java_post_build_commands(self) -> list[str]:
return link_java + link_jars


class PluginModel(PluginPropertiesModel):
"""Model for plugins using pydantic validation.
Plugins with configuration properties can use pydantic validation to unmarshal
data from part specs. In this case, extract plugin-specific properties using
the :func:`extract_plugin_properties` helper.
"""


def extract_plugin_properties(
data: dict[str, Any], *, plugin_name: str, required: list[str] | None = None
) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/cmake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

from overrides import override

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class CMakePluginProperties(PluginProperties, PluginModel):
class CMakePluginProperties(PluginProperties):
"""The part properties used by the cmake plugin."""

cmake_parameters: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/dotnet_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
from overrides import override

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)


class DotnetPluginProperties(PluginProperties, PluginModel):
class DotnetPluginProperties(PluginProperties):
"""The part properties used by the Dotnet plugin."""

dotnet_build_configuration: str = "Release"
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/go_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from craft_parts import errors

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)


class GoPluginProperties(PluginProperties, PluginModel):
class GoPluginProperties(PluginProperties):
"""The part properties used by the Go plugin."""

go_buildtags: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/make_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

from overrides import override

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class MakePluginProperties(PluginProperties, PluginModel):
class MakePluginProperties(PluginProperties):
"""The part properties used by the make plugin."""

make_parameters: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/maven_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
from craft_parts import errors

from . import validator
from .base import JavaPlugin, PluginModel, extract_plugin_properties
from .base import JavaPlugin, extract_plugin_properties
from .properties import PluginProperties


class MavenPluginProperties(PluginProperties, PluginModel):
class MavenPluginProperties(PluginProperties):
"""The part properties used by the maven plugin."""

maven_parameters: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/meson_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from overrides import override

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)


class MesonPluginProperties(PluginProperties, PluginModel):
class MesonPluginProperties(PluginProperties):
"""The part properties used by the Meson plugin."""

meson_parameters: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/npm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from craft_parts.errors import InvalidArchitecture

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)
Expand All @@ -47,7 +47,7 @@
_NODE_ARCH_FROM_PLATFORM = {"x86_64": {"32bit": "x86", "64bit": "x64"}}


class NpmPluginProperties(PluginProperties, PluginModel):
class NpmPluginProperties(PluginProperties):
"""The part properties used by the npm plugin."""

# part properties required by the plugin
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/python_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

from overrides import override

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class PythonPluginProperties(PluginProperties, PluginModel):
class PythonPluginProperties(PluginProperties):
"""The part properties used by the python plugin."""

python_requirements: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/qmake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from overrides import override
from typing_extensions import Self

from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class QmakePluginProperties(PluginProperties, PluginModel):
class QmakePluginProperties(PluginProperties):
"""The part properties used by the qmake plugin."""

qmake_parameters: list[str] = []
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/rust_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pydantic import validator as pydantic_validator

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties

logger = logging.getLogger(__name__)
Expand All @@ -46,7 +46,7 @@ def _validate_list_is_unique(value: list) -> list:
UniqueStrList = Annotated[list[str], AfterValidator(_validate_list_is_unique)]


class RustPluginProperties(PluginProperties, PluginModel):
class RustPluginProperties(PluginProperties):
"""The part properties used by the Rust plugin."""

# part properties required by the plugin
Expand Down
4 changes: 2 additions & 2 deletions craft_parts/plugins/scons_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from craft_parts import errors

from . import validator
from .base import Plugin, PluginModel, extract_plugin_properties
from .base import Plugin, extract_plugin_properties
from .properties import PluginProperties


class SConsPluginProperties(PluginProperties, PluginModel):
class SConsPluginProperties(PluginProperties):
"""The part properties used by the SCons plugin."""

scons_parameters: list[str] = []
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/lifecycle/test_plugin_changesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def teardown_module():
plugins.unregister_all()


class ExamplePluginProperties(plugins.PluginProperties, plugins.PluginModel):
class ExamplePluginProperties(plugins.PluginProperties):
"""The application-defined plugin properties."""

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/plugins/test_application_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from craft_parts import Action, ActionType, Step, errors, plugins


class AppPluginProperties(plugins.PluginProperties, plugins.PluginModel):
class AppPluginProperties(plugins.PluginProperties):
"""The application-defined plugin properties."""

app_stuff: list[str]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/plugins/test_validate_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def mytool_error(new_dir):
return tool


class AppPluginProperties(plugins.PluginProperties, plugins.PluginModel):
class AppPluginProperties(plugins.PluginProperties):
"""The application-defined plugin properties."""

@classmethod
Expand Down

0 comments on commit 257af9f

Please sign in to comment.