-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
Despite what is mentioned in docs, I still see errors when adding a factory to the registry using NewType.
This is a sample file where I see the errors on Python 3.12 + svcs 25.1:
from collections.abc import Iterator
from contextlib import contextmanager
from typing import NewType
import svcs
from sqlmodel import Session, create_engine
ContactsDB = NewType("ContactsDB", Session)
@contextmanager
def create_contacts_db() -> Iterator[Session]:
engine = create_engine("sqlite:///data/wa.db")
with Session(engine) as session:
yield session
registry = svcs.Registry()
registry.register_factory(ContactsDB, create_contacts_db)This is the error I see:
registry.py
registry.py:20:1 - warning: Type of "register_factory" is partially unknown
Type of "register_factory" is "(svc_type: type, factory: (...) -> Unknown, *, enter: bool = True, ping: ((...) -> Unknown) | None = None, on_registry_close: ((...) -> Unknown) | Awaitable[Unknown] | None = None) -> None" (reportUnknownMemberType)
registry.py:20:27 - error: Argument of type "type[ContactsDB]" cannot be assigned to parameter "svc_type" of type "type" in function "register_factory"
"FunctionType" is not assignable to "type" (reportArgumentType)
Reactions are currently unavailable