Skip to content

Commit 11b52e2

Browse files
committed
Add more information to a comment
1 parent 37e071e commit 11b52e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

injector/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ def __init__(self, parent: 'Binder') -> None:
351351
self._binder = Binder(parent.injector, auto_bind=False, parent=parent)
352352

353353
def append(self, provider: Provider[T], scope: Type['Scope']) -> None:
354-
# HACK: generate a pseudo-type for this element in the list
355-
pseudo_type = type(f"pseudo-type-{id(provider)}", (provider.__class__,), {})
354+
# HACK: generate a pseudo-type for this element in the list.
355+
# This is needed for scopes to work properly. Some, like the Singleton scope,
356+
# key instances by type, so we need one that is unique to this binding.
357+
pseudo_type = type(f"multibind-type-{id(provider)}", (provider.__class__,), {})
356358
self._multi_bindings.append(Binding(pseudo_type, provider, scope))
357359

358360
def get_scoped_providers(self, injector: 'Injector') -> Generator[Provider[T], None, None]:

0 commit comments

Comments
 (0)