diff --git a/dependency_injector/injections.py b/dependency_injector/injections.py index ac52dc9c..14c9bd68 100644 --- a/dependency_injector/injections.py +++ b/dependency_injector/injections.py @@ -15,6 +15,13 @@ from dependency_injector import errors def inject(*args, **kwargs): """Dependency injection decorator. + .. warning:: + + :py:func:`inject` decorator has been deprecated since version 2.2.0. + + Usage of :py:func:`inject` decorator can lead to bad design and could + be considered as anti-pattern. + :py:func:`inject` decorator can be used for making inline dependency injections. It patches decorated callable in such way that dependency injection will be done during every call of decorated callable. diff --git a/docs/advanced_usage/index.rst b/docs/advanced_usage/index.rst index 2f5f7176..cd4ce33a 100644 --- a/docs/advanced_usage/index.rst +++ b/docs/advanced_usage/index.rst @@ -9,6 +9,10 @@ Current section of documentation describes advanced usage of .. currentmodule:: dependency_injector.injections +.. warning:: + + :py:func:`inject` decorator has been deprecated since version 2.2.0. + :py:func:`inject` decorator is a part of :py:mod:`dependency_injector.injections` module. diff --git a/docs/api/index.rst b/docs/api/index.rst index ad06c9d9..1f1df940 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -7,6 +7,5 @@ API Documentation top_level providers containers - injections utils errors diff --git a/docs/examples/index.rst b/docs/examples/index.rst index 907553f5..89d623fb 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -9,8 +9,8 @@ Examples "Dependency Injector" framework. Current section of documentation is designed to provide several example mini -applications that are built on the top of inversion of control principle and -powered by *Dependency Injector* framework. +applications that are built according to the inversion of control principle +and powered by *Dependency Injector* framework. .. toctree:: :maxdepth: 2 diff --git a/docs/examples/movie_lister.rst b/docs/examples/movie_lister.rst index 2fbd4635..c982746d 100644 --- a/docs/examples/movie_lister.rst +++ b/docs/examples/movie_lister.rst @@ -20,14 +20,14 @@ Like Martin says: While original Martin's MovieLister example was a bit modified here, it makes sense to provide some description. So, the idea of this example is to -create ``movies`` library that can be configurable to work with different -movie databases (csv, sqlite) and provide 2 main features: +create ``movies`` library that can be configured to work with different +movie databases (csv, sqlite, etc...) and provide 2 main features: 1. List all movies that were directed by certain person. 2. List all movies that were released in certain year. Also this example contains 3 mini applications that are based on ``movies`` -library : +library: 1. ``app_csv.py`` - list movies by certain criteria from csv file database. 2. ``app_db.py`` - list movies by certain criteria from sqlite database. @@ -38,8 +38,6 @@ Instructions for running: .. code-block:: bash - python create_db.py - python app_csv.py python app_db.py python app_db_csv.py @@ -74,6 +72,30 @@ Listing of ``movies/__init__.py``: :language: python :linenos: +Example application +~~~~~~~~~~~~~~~~~~~ + +Example application structure: + +.. code-block:: bash + + /example + /__init__.py + /db.py + /main.py + +Listing of ``examples/main.py``: + +.. literalinclude:: ../../examples/miniapps/movie_lister/example/main.py + :language: python + :linenos: + +Listing of ``examples/db.py``: + +.. literalinclude:: ../../examples/miniapps/movie_lister/example/db.py + :language: python + :linenos: + Csv application ~~~~~~~~~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index 7eefdb52..9ac141f1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -59,7 +59,6 @@ Contents main/installation providers/index containers/index - advanced_usage/index examples/index api/index main/feedback diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index 3366a0ee..6d04874d 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -9,7 +9,7 @@ follows `Semantic versioning`_ Development version ------------------- -- No features. +- Deprecate ``inject`` decorator. 2.1.1 ----- diff --git a/examples/miniapps/movie_lister/app_csv.py b/examples/miniapps/movie_lister/app_csv.py index 75dfef42..e7aaa310 100644 --- a/examples/miniapps/movie_lister/app_csv.py +++ b/examples/miniapps/movie_lister/app_csv.py @@ -12,8 +12,8 @@ csv file movies database. import movies import movies.finders -import example.main import example.db +import example.main import settings diff --git a/examples/miniapps/movie_lister/app_db.py b/examples/miniapps/movie_lister/app_db.py index 8f15e524..708ba287 100644 --- a/examples/miniapps/movie_lister/app_db.py +++ b/examples/miniapps/movie_lister/app_db.py @@ -14,8 +14,8 @@ import sqlite3 import movies import movies.finders -import example.main import example.db +import example.main import settings diff --git a/examples/miniapps/movie_lister/app_db_csv.py b/examples/miniapps/movie_lister/app_db_csv.py index b7461430..de83e12f 100644 --- a/examples/miniapps/movie_lister/app_db_csv.py +++ b/examples/miniapps/movie_lister/app_db_csv.py @@ -14,8 +14,8 @@ import sqlite3 import movies import movies.finders -import example.main import example.db +import example.main import settings