Coder Social home page Coder Social logo

@Requires decorator can be inherit about ipopo HOT 3 OPEN

pisua avatar pisua commented on June 26, 2024
@Requires decorator can be inherit

from ipopo.

Comments (3)

tcalmant avatar tcalmant commented on June 26, 2024

I have troubles replicating the issue, you can find my test bundle below.
It creates 3 components providing dummy services, a GrandParent class (not a factory) declaring a single @Requires, inherited by a Parent component factory with its own requirement, itself inherited by the Childcomponent factory.

Even when commenting the @Requires (toto) of Parent, the child still has the other two requirements injected.

Do you have a sample code to see what happens ?
Which version of iPOPO are you using ?

from pelix.ipopo.decorators import (
    ComponentFactory,
    Requires,
    Instantiate,
    Validate,
    Provides,
)
from pelix.framework import create_framework

@ComponentFactory()
@Provides("foo")
@Instantiate("foo")
class Foo:
    pass

@ComponentFactory()
@Provides("bar")
@Instantiate("bar")
class Bar:
    pass

@ComponentFactory()
@Provides("baz")
@Instantiate("baz")
class Baz:
    pass

@Requires("tutu", "baz")
class GrandParent:
    def __init__(self):
        self.tutu = None

@ComponentFactory()
@Requires("toto", "foo")
@Instantiate("parent")
class Parent(GrandParent):
    def __init__(self):
        super().__init__()
        self.toto = None

    @Validate
    def validate(self, ctx):
        print("Parent ## tutu=", self.tutu, "toto=", self.toto)

@ComponentFactory()
@Requires("titi", "bar")
@Instantiate("child")
class Child(Parent):
    def __init__(self):
        super().__init__()
        self.titi = None

    @Validate
    def validate(self, ctx):
        print(
            "Child ## tutu=", self.tutu, "toto=", self.toto, "titi=", self.titi
        )

Here is a sample output:

Child ## tutu= <check.Baz object at 0x00000209D2BB2940> toto= <check.Foo object at 0x00000209D2BED320> titi= <check.Bar object at 0x00000209D2BB2978>
Parent ## tutu= <check.Baz object at 0x00000209D2BB2940> toto= <check.Foo object at 0x00000209D2BED320>

from ipopo.

pisua avatar pisua commented on June 26, 2024

I'll see to provide you asap the code sample.

from ipopo.

tcalmant avatar tcalmant commented on June 26, 2024

No news on this issues and I couldn't reproduce it.
Moving it to milestone 0.8.1 waiting for more details.

from ipopo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.