Mityuha / fresh-bakery

Bake dependency injections asynchronously and stupidly simple
https://fresh-bakery.readthedocs.io/en/latest/
MIT License
21 stars 0 forks source link

Another Bakery Attribute Unpacking #38

Closed Mityuha closed 7 months ago

Mityuha commented 10 months ago

Let's suppose you have a bakery

class MyBakery(Bakery):
    endpoints: dict = Cake({...})

And have another bakery that includes the former

class MyBakery2(Bakery):
    my_bakery: MyBakery = Cake(Cake(MyBakery))
    all_endpoint: dict = Cake({**my_bakery.endpoints})

Now the error occured while import

    all_endpoint: dict = Cake({**my_bakery.endpoints})
bakery/piece_of_cake.py:82: in __call__
    cake = cake()
bakery/cake.py:93: in __call__
    assert_baked(cast(Cakeable[Any], self))
bakery/stuff.py:205: in assert_baked
    raise ValueError(f"{cake} is not baked. Just bake it!")
E   ValueError: Cake '<anon>' is not baked. Just bake it!

Or unpacking a sequence

    all_endpoint: list = Cake([*my_bakery.endpoints])
bakery/piece_of_cake.py:57: in __iter__
    raise ValueError("Piece of cake is not iterable")
E   ValueError: Piece of cake is not iterable

Maybe it's worth supporting it to get an opportunity to write completely separated containers that can be merged into single one.

Mityuha commented 10 months ago

Won't be fixed. See PR #39 example

Mityuha commented 7 months ago

Won't be fixed