diff --git a/src/e3/anod/spec.py b/src/e3/anod/spec.py index a9e2f1a0..41f7c005 100644 --- a/src/e3/anod/spec.py +++ b/src/e3/anod/spec.py @@ -203,6 +203,26 @@ class MyProduct(Anod): ExternalSourceBuilder = e3.anod.package.ExternalSourceBuilder ThirdPartySourceBuilder = e3.anod.package.ThirdPartySourceBuilder + def __new__(cls, *args: Any, **kwargs: Any) -> Any: + """Replace `method` by property when decorator is missing.""" + should_be_property = ( + "enable_name_generator", + "readme_info", + "base_name", + "build_space_name", + "has_package", + "package", + "component", + "source_pkg_build", + ) + + for prop in should_be_property: + class_property = getattr(cls, prop) + if callable(class_property): + setattr(cls, prop, property(fget=class_property)) + + return super().__new__(cls) + def __init__( self, qualifier: str, diff --git a/tests/tests_e3/anod/spec_test.py b/tests/tests_e3/anod/spec_test.py index b4772b0b..eacbd273 100644 --- a/tests/tests_e3/anod/spec_test.py +++ b/tests/tests_e3/anod/spec_test.py @@ -147,3 +147,12 @@ class GeneratorDisabled(Anod): assert spec_enable.args == {"q1": True} assert spec_disable.args == {"q1": ""} + + +def test_missing_property(): + class NoProperty(Anod): + def source_pkg_build(self) -> list: + return [] + + noproperty = NoProperty(qualifier="", kind="source") + assert noproperty.source_pkg_build == []