Skip to content

Commit

Permalink
Release version 1.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
raceychan committed Feb 3, 2025
1 parent 6cca658 commit 2279f40
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 124 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,16 @@ and such override won't affect others.
## version 1.3.5
a quick bug fix, where in 1.3.4, registered_singleton is not shared between graph and scope.
- a quick bug fix, where in 1.3.4, registered_singleton is not shared between graph and scope.
The general rule is that scope can access registered singletons and resolved instances but not vice versa.
## version 1.3.6
- Fix: `Graph.entry` no longer uses existing scope, instead, always create a new scope
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ async def main(command: CreateUser, uow: UnitOfWork):
await main(CreateUser(name='user'))
```

To resolve `AsyncConnection` outside of entry function

```python
from ididi import Graph

dg = Graph()

async with dg.scope():
conn = await scope.resolve(conn_factory)
```


### Dependency factory

Expand Down Expand Up @@ -108,7 +119,17 @@ Check out `tests/features/test_typing_support.py` for examples.

### Scope

Using Scope to manage resources
`Scope` is a temporary view of the graph specialized for handling resources.

In a nutshell:

- Scope can access registered singletons and resolved instances of its parent graph

- its parent graph can't access its registered singletons and resolved resources.

- Non-resource instances resolved by the scope can be access by its parent graph

#### Using Scope to manage resources

- **Infinite number of nested scope**
- **Parent scope can be accssed by its child scopes(within the same context)**
Expand Down
8 changes: 4 additions & 4 deletions ididi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
license: MIT, see LICENSE for more details.
"""

VERSION = "1.3.5"
VERSION = "1.3.6"

__version__ = VERSION

Expand All @@ -25,13 +25,13 @@
from .api import entry as entry
from .api import resolve as resolve
from .graph import AsyncScope as AsyncScope
from .graph import DependencyGraph as DependencyGraph
from .graph import Graph as Graph
from .graph import SyncScope as SyncScope
from .graph import DependencyGraph as DependencyGraph
from .interfaces import AsyncResource as AsyncResource
from .interfaces import INode as INode
from .interfaces import INodeConfig as INodeConfig
from .utils.typing_utils import AsyncResource as AsyncResource
from .utils.typing_utils import Resource as Resource
from .interfaces import Resource as Resource

try:
import graphviz as graphviz # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions ididi/_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
### a readonly view of GraphNodes
"""

ResolvedInstances = dict[type[T], T]
ResolvedSingletons = dict[type[T], T]
"""
mapping a type to its resolved instance
mapping a type to its resolved instance, only instances of reusable node will be added here.
"""

TypeMappings = dict[type[T], list[type[T]]]
Expand Down
Loading

0 comments on commit 2279f40

Please sign in to comment.