Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Jul 26, 2024
1 parent 118d19e commit b971f1c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ Easy dependency injection for all, works with Python 3.8-3.12. Main features and
* **multiple containers**;
* **overriding** dependencies for tests without wiring;
* **100%** code coverage and very simple code;
* good [documentation](https://injection.readthedocs.io/latest/).
* good [documentation](https://injection.readthedocs.io/latest/);
* intuitive and almost identical api with [dependency-injector](https://github.com/ets-labs/python-dependency-injector),
which will allow you to easily migrate to injection
(see [migration from dependency injector](https://injection.readthedocs.io/latest/introduction/migration-from-dependency-injector.html));

---

Expand Down
30 changes: 30 additions & 0 deletions docs/dev/migration-from-dependency-injector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Migration from Dependency Injector

If you have already used a wonderful package
[dependency-injector](https://github.com/ets-labs/python-dependency-injector),
then you probably know that there have been no new versions for a long time.
It also lacks integration with FastAPI, for example to determine dependencies with **Annotated**
(see [issues](https://github.com/ets-labs/python-dependency-injector/issues?q=is%3Aissue+is%3Aopen+annotated)).
[Injection](https://github.com/nightblure/injection) package has an almost identical API to the [dependency-injector](https://github.com/ets-labs/python-dependency-injector)
and eliminates its shortcomings, which will make migrating very easy.

---

⚠️ **IMPORTANT**

[Injection](https://github.com/nightblure/injection) **does not implement** **some** [providers](https://python-dependency-injector.ets-labs.org/providers/index.html)
(Resource, List, Dict, Aggregate and etc.) because the developer considered them to be **rarely used** in practice.
In this case, you don't need to do the migration, but if you really want to use my package,
I'd love to see your [issues](https://github.com/nightblure/injection/issues) and/or [MR](https://github.com/nightblure/injection/pulls)!

---

To **migrate**, follow these **steps**:
1. **Replace imports**:
* `from dependency_injector import providers` -> `from injection import providers`;

* `from dependency_injector.wiring import Provide, inject` -> `from injection import Provide, inject`

* `from dependency_injector.containers import DeclarativeContainer` -> `from injection import DeclarativeContainer`

2. **Replace method call**: `some_container.override_providers(**overrides)` -> ``some_container.override_providers(overrides)``
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
.. toctree::
:maxdepth: 1
:caption: For developers
:caption: DEV section
dev/migration-from-dependency-injector
dev/contributing
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ The public API of this framework is almost completely identical to
because the author found it successful and understandable.
In addition, this will provide an easy migration to the current framework with
[Dependency Injector](https://python-dependency-injector.ets-labs.org/index.html#)
(see section migration from Dependency Injector).
(see [migration from Dependency Injector](https://injection.readthedocs.io/latest/introduction/migration-from-dependency-injector.html)).

## Features

* providers - delegate object creation and lifecycle management to providers;
* support Python 3.8-3.12;
* works with FastAPI, Flask, Django, Litestar;
* works with FastAPI, Flask, Django REST Framework, Litestar;
2 changes: 1 addition & 1 deletion docs/introduction/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`Injection` works with Python versions 3.8-3.12 and is available on PyPI.
To install the latest version you can use pip:
```bash
pip install injection
pip install deps-injection
```

`Injection` versioned according to [Semantic Versioning](https://semver.org/).
Expand Down

0 comments on commit b971f1c

Please sign in to comment.