hynek / svcs

A Flexible Service Locator for Python.
https://svcs.hynek.me
MIT License
294 stars 19 forks source link

Unexpected TypeError: Factories must take 0 or 1 parameters. #109

Open spacemanspiff2007 opened 13 hours ago

spacemanspiff2007 commented 13 hours ago

This works:

async with aiohttp.ClientSession() as client:
    html = await fetch(client)
    print(html)

This throws an unexpected error

from typing import Final

import svcs
from aiohttp import ClientSession

REGISTRY: Final = svcs.Registry()
REGISTRY.register_factory(ClientSession, ClientSession)
..\src\my_file.py:9: in <module>
    REGISTRY.register_factory(ClientSession, ClientSession)
..\.venv\Lib\site-packages\svcs\_core.py:254: in register_factory
    rs = self._register_factory(
..\.venv\Lib\site-packages\svcs\_core.py:329: in _register_factory
    svc_type, factory, _takes_container(factory), enter, ping
..\.venv\Lib\site-packages\svcs\_core.py:433: in _takes_container
    raise TypeError(msg)
E   TypeError: Factories must take 0 or 1 parameters.