Open
Description
Given python-dependency-injector@4.35.2
# my_module.py
from typing import Any
from dependency_injector import resources
class MyDep:
...
class MyDepAsyncResource(resources.AsyncResource[MyDep]):
async def init(self, *args: Any, **kwargs: Any) -> MyDep:
return MyDep()
async def shutdown(self, resource: MyDep) -> None:
...
# oh_no.py
from my_module import MyDepAsyncResource
Fails to run on python 3.8.9 with
$python oh_no.py
oh_no.py:1: in <module>
from my_module import MyDepAsyncResource
my_module.py:7: in <module>
class MyDepAsyncResource(resources.AsyncResource[MyDep]):
../../../Library/Caches/pypoetry/virtualenvs/xxxxxxx-py3.8/lib/python3.8/site-packages/dependency_injector/resources.py:20: in __getitem__
return cls(item)
../../../.pyenv/versions/3.8.9/lib/python3.8/typing.py:875: in __new__
obj = super().__new__(cls, *args, **kwds)
E TypeError: object.__new__() takes exactly one argument (the type to instantiate)
Removing this seems to fix it
python-dependency-injector/src/dependency_injector/resources.py
Lines 18 to 20 in 155f598
What's that for?