File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -234,8 +234,8 @@ container.add_transient_by_factory(my_factory) # <-- MyClass is used as Key.
234234
235235## Working with generics
236236
237- Generic types are supported. The following example provides a meaningful
238- demonstration of generics with ` TypeVar ` in a real-world scenario.
237+ Generic types are supported. The following example provides a demonstration of
238+ generics with ` TypeVar ` in a real-world scenario.
239239
240240``` python {linenums="1", hl_lines="9 43-44 47-48"}
241241from dataclasses import dataclass
@@ -246,7 +246,7 @@ from rodi import Container
246246T = TypeVar(" T" )
247247
248248
249- class Repository (Generic[T]): # interface
249+ class Repository (Generic[T]):
250250 """ A generic repository for managing entities of type T."""
251251
252252 def __init__ (self ):
@@ -309,8 +309,9 @@ The above prints to screen:
309309 type: warning
310310
311311Note how the generics ` Repository[Product] ` and ` Repository[Customer] ` are both
312- configured to be resolved using ` Repository ` as concrete type. ` GenericAlias `
313- in Python is not considered an actual class. The following wouldn't work:
312+ configured to be resolved using ` Repository ` as concrete type. Instances of
313+ ` GenericAlias ` are not considered as actual classes. The following wouldn't
314+ work:
314315
315316``` python
316317container.add_scoped(Repository[Product]) # No. 💥
You can’t perform that action at this time.
0 commit comments