dic icon indicating copy to clipboard operation
dic copied to clipboard

Return type for the __init__ method (None)

Open nme01 opened this issue 7 years ago • 3 comments

When one tries to write a type annotation for the __init__ method, the container will try to resolve this type (which is None) and this will cause an error.

nme01 avatar Jul 31 '17 16:07 nme01

Thanks for raising this, much appreciated. Do you have a small code sample that replicates this? Would also help to know what version of Python you're running.

zsims avatar Jul 31 '17 21:07 zsims

I'm using Python 3.5.1. Here's the code.

from dic.container import ContainerBuilder


class Dummy(object):
    def __init__(self) -> None:
        pass


builder = ContainerBuilder()
builder.register_class(Dummy)

container = builder.build()

container.resolve(Dummy)

nme01 avatar Aug 01 '17 08:08 nme01

Thanks for the code. I'll look at fixing this, plus setting up Python 3.5 tests -- there's a fair bit that changed

zsims avatar Aug 01 '17 22:08 zsims